
有一个问题:AngularJS-UI-router-如何使用一个答案配置动态视图,该示例显示了如何执行此 *** 作。
[$ urlRouterProvider.deferIntercept(defer)](http://angular-怎么了?刷新时,将
url尽快评估,然后注册状态。我们必须推迟。解决方案由UI-Router本机功能驱动deferIntercept(defer)
ui.github.io/ui-router/site/#/api/ui.router.router.$urlRouterProvider)
如文档中所述:
禁用 _ (或启用)_ 延迟位置更改拦截。
如果您希望自定义同步URL的行为(例如,如果您希望推迟转换但保留当前URL),请在配置时调用此方法。然后,在运行时,
$urlRouter.listen()在配置了自己的$locationChangeSuccess事件处理程序之后调用。
简而言之,我们将在配置阶段停止URL处理:
app.config(function ($urlRouterProvider) { // Prevent $urlRouter from automatically intercepting URL changes; // this allows you to configure custom behavior in between // location changes and route synchronization: $urlRouterProvider.deferIntercept();})一旦我们从JSON配置了所有动态状态,我们就会在.run()阶段重新启用它:
.run(function ($rootScope, $urlRouter, UserService) { ... // once the user has logged in, sync the current URL // to the router: $urlRouter.sync(); // Configures $urlRouter's listener *after* your custom listener $urlRouter.listen();});欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)