我试图在 gulp webpack setup 中升级到 ui-router 1.0.0-rc.1 。我无法弄清楚如何从服务器实现加载状态并为其注册未来状态。
我想要实现的是拥有一个landing
父状态。状态将从服务器加载,服务器是一个状态数组,如landing.<state-name>
.
$stateProvider
.state('landing', {
url: '/',
abstract: true,
component: 'landing',
})
.state('landing.**', {
url: '/',
lazyLoad: function (transition) {
return transition.injector().get('$http').get('/getStates').then(function (result) {
var arr = [];
angular.forEach(result, function (state) {
arr.push({
name: 'landing.' + state.state_name,
url: state.url,
templateUrl: state.partial_path
});
});
return arr;
});
}
})
我可以在控制台中看到以下内容。
Transition #0 r0: Started -> "Transition#0( ''{} -> 'landing.**'{"remainder":"dashboard"} )"
[Violation] Long running JavaScript task took 284ms
trace.js:192 Transition #0 r0: <- Rejected "Transition#0( ''{} -> 'landing.**'{"remainder":"dashboard"} )", reason: TransitionRejection(type: 2, message: The transition has been superseded by a different transition, detail: 'landing.**'{"remainder":"dashboard"})
trace.js:150 Transition #1 r0: Started -> "Transition#1( ''{} -> 'landing.**'{"remainder":"dashboard"} )"
trace.js:199 Transition #1 r0: <- Success "Transition#1( ''{} -> 'landing.**'{"remainder":"dashboard"} )", final state: landing.**
stats.js:103 Font Awesome CDN reporting has been enabled
文档不够清晰,所以我有点卡住了。
任何帮助表示赞赏