这是我的第一个角度项目,我在我的应用程序中使用了角度“ui.router”。 This is structure of my application
我为每个模块创建了单独的路径文件,所有模块都在app.js中注入。当我运行我的应用程序时,我的家庭模块路由工作正常,但帐户模块路由提供以下错误:
**“错误:无法从状态''解析'登录' transitionTo ................
但是当我在路线文件中直接创建帐户模块控制器时,它可以正常工作。我坚持这个
任何人都可以解决此问题吗?
答案 0 :(得分:0)
在父模块中注入uiRouter模块配置状态。
var myApp = angular.module('myApp',['ui.router']);
myApp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/state1");
// Now set up the states
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
})
.state('state1.list', {
url: "/list",
templateUrl: "partials/state1.list.html",
controller: function($scope) {
$scope.items = ["A", "List", "Of", "Items"];
}
})
.state('state2', {
url: "/state2",
templateUrl: "partials/state2.html"
})
.state('state2.list', {
url: "/list",
templateUrl: "partials/state2.list.html",
controller: function($scope) {
$scope.things = ["A", "Set", "Of", "Things"];
}
});
});