对Ember中的Request Lifecycle Hooks有什么好的参考吗?

时间:2014-10-15 14:26:08

标签: ember.js

我最近有一个错误,其中我在路由的afterModel挂钩中编写的一段代码无效,因为我需要引用当时不可用的路由控制器。这让我开始寻找资源来了解各种Ember中钩子的排序和细节。

我发现的唯一优秀资源是一个博文:Router Request Lifecycle列出:

- enter (private)
- activate - executed when entering the route
- deserialize (private)
- model (formely deserialize) - takes the params and returns a model which is set to the route’s currentModel
- serialize - used to generate dynamic segments in the URL from a model
- setupController - takes currentModel and sets it to the controller’s content by default
- renderTemplate - takes current controller and what model returns and renders the template

具有适当的名称 deactivate - 退出路径时执行(由内部退出调用) 退出(私有,需要调用this._super)

虽然指南中不同地提到了所有这些钩子,但官方指南中没有有组织的资源按时间顺序列出各种钩子,并解释了博客文章。请不要只要说“阅读指南”

所以我很想知道是否有任何其他资源显示在视图,模型,控制器或模板设置上如何调用钩子的时间顺序。

1 个答案:

答案 0 :(得分:2)

感谢@ teddyzeenny这里有一个jsbin,它显示模型上按什么顺序触发的内容:

"before model"
"model"
"after model"
"activate"
"setup controller"
相关问题