[英]transition parameter in afterModel emberjs
i don't understand why the afterModel
method get a transition
parameter, and what its represent (yeah a transition from one page to the other, but in afterModel
method there is no transition running, and that the prupose of afterModel
, starting a transition if required, using model data.) 我不明白afterModel
方法为什么会得到一个transition
参数,它代表什么(是的,从一页到另一页的过渡,但是在afterModel
方法中没有运行过渡,而afterModel
的目的是在过渡时开始必需的,使用模型数据。)
http://emberjs.com/api/classes/Ember.Route.html#method_afterModel http://emberjs.com/api/classes/Ember.Route.html#method_afterModel
The afterModel
hook is the third of the three model hookes, which all run before the transition is done. afterModel
挂钩是三个模型挂钩中的第三个,它们均在转换完成之前运行。
So the transition in afterModel
is the same then in beforeModel
. 因此,在过渡afterModel
然后在同一beforeModel
。
The difference is that sometimes you need the model to decide if you want to abort the transition and redirect to somewhere else or not. 不同之处在于,有时您需要模型来决定是否要中止转换并重定向到其他位置。
A example could be a /userEdit/:user_id
route where admins can edit all users and normal users only can edit their own user. 一个示例可以是/userEdit/:user_id
路由,其中管理员可以编辑所有用户,而普通用户只能编辑自己的用户。 In the beforeModel
you could check if the the user is admin and if not but you can't abort the transition based on information on the model. 在beforeModel
您可以检查用户是否为admin,如果不是,则不能根据模型上的信息中止转换。 In the atferModel
hook you can do exactly this, and save the transition away to may retry it later, for example after the user got admin privileges. 在atferModel
挂钩中,您可以执行此操作,并将转换保存下来,以便稍后再试,例如,在用户获得管理员权限之后。
The router does not enter the route after the Promise returned by the afterModel
hook resolves. 路由器不进入航线后的无极返回由afterModel
钩消退。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.