[英]AngularJS - Dynamic $StateProvider With UI-Router Views and $ocLazyLoad Resolves Syntax
[英]Angular ui-router and ocLazyLoad
場景:
我有一些角度模塊,例如:
angular.module('app', ['app.core', 'app.views']); // not lazy load
app.views
下的每個模塊app.views
使用RouterUtil來注冊自己的路由,例如:
$stateProvider.state('state name', {/* some configs here */});
該RouterUtil還具有一種訪問所有注冊狀態的方法(用於創建動態菜單)。
我正在使用ocLazyLoad ,只是用來加載外部模塊。 當頁面加載時,ocLazyLoad將使用一些角度模塊向其他js執行請求,然后將該模塊添加到實際環境中 。
當我轉到此外部模塊的頁面並嘗試刷新頁面時,會發生問題:
怎么了:
我可以在檢查ocLazyLoad請求之前是否先讓ui-router等待它是否為已注冊URL?
您想使用deferIntercept()
,以延遲ui-router觀看URL。
app.config(function($urlRouterProvider) {
urlRouterProvider.deferIntercept();
});
... ocLazyLoad stuff
app.run(function($urlRouter) {
ocLazyLoadPromise.then(function() { urlRouter.listen(); });
});
http://angular-ui.github.io/ui-router/site/#/api/ui.router.router。$ urlRouterProvider
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.