我尝试从应用中的某个状态转到另一个状态时出错。
我在索引文件中定义了所有状态。
index.js
var MyModule = angular.module('myApp.ui.moduleTest', [
'ui.router'
])
.config(function($stateProvider, modalStateProvider){
$stateProvider
.state('myApp.dashboard.appArea.moduleTest',
modalStateProvider.create({
animation: true,
name: 'myApp.dashboard.appArea.moduleTest',
url: 'apps/moduleTest',
controllerAs: 'moduleTestCtrl',
controller: 'ModuleTestCtrl',
windowClass: 'semi-modal semi-modal--huge',
templateUrl: function() {
return 'app/ui/apps/moduleTest/widget.html';
},
resolve: {
//Some function to retrieve data
}
})
)
.state('myApp.dashboard.appArea.moduleTest.wizards',
modalStateProvider.create({
animation: true,
name: 'myApp.dashboard.appArea.moduleTest.wizards',
url: 'apps/moduleTest/runWizard',
controllerAs: 'moduleTestWizardCtrl',
controller: 'ModuleTestWizardCtrl',
templateUrl: function(){
return 'app/ui/apps/moduleTest/wizard.html';
}
// resolve: {
//
// }
})
)
})
当我处于状态“myApp.dashboard.appArea.moduleTest”Fron ModuleTestCtrl时我正试图进入状态“myApp.dashboard.appArea.moduleTest.wizards”但是我收到错误“无法解决状态”。如何在控制器中导入此配置模块以导航到该状态?
/*jslint node: true */
'use strict';
var angular = require('angular');
function ModuleTestCtrl($uibModalInstance, Api, diagnosticsRaw, myService, $state) {
this.$uibModalInstance = $uibModalInstance;
this.Api = Api;
this.dataRaw = diagnosticsRaw;
this.parserData = function(indexes) {
//Some app logic irrelevant
}
myService.setPropertyToRun(this.dataRaw);
myService.setIsPropertyToRun(true);
$state.go('myApp.dashboard.appArea.moduleTest.wizards'); //THIS IS WHERE I HAVE MY PROBLEM
};
}
ModuleTestCtrl。$ inject = ['$ uibModalInstance','Api','diagnosticsRaw','myService','$ state']; module.exports = ModuleTestCtrl;
答案 0 :(得分:1)
您是否在angular.config中描述了myApp.dashboard.appArea.moduleTest
和myApp.dashboard.appArea.moduleTest.wizards
的所有父状态,否则可能是问题。
例:
向导是moduleTest的子节点,它是appArea的子节点,它是仪表板的子节点,它是myApp的子节点,你明白了。您首先需要声明所有这些父状态,即使它们可能没有做任何事情。
更多关于ui-state的信息:
https://github.com/angular-ui/ui-router/wiki/Nested-States-and-Nested-Views