我使用ui-router
,但ui-router
无法找到我的状态之一:Could not resolve 'main.tabs' from state 'main'
。我发现config
模块的tabs
未被调用,因此main.tabs
未注册。
初始状态:$urlRouterProvider.otherwise('/main/dashboard');
使用main.tabs
<a ui-sref="main.tabs" class="item" ng-click="toggleMenu()">Tabs</a>
的index.html
<script src="app/main/main.js"></script>
<script src="app/tabs/tabs.js"></script>
<script src="app/dashboard/dashboard.js"></script>
<script src="app/app.js"></script>
main.js
var main = angular.module('main', []);
main.config(function ($stateProvider) {
$stateProvider
.state('main', {
url: "/main",
abstract: true,
templateUrl: "./app/main/main.html"
});
});
tabs.js
var tabs = angular.module('tabs', ['main']);
tabs.config(function ($stateProvider) {
$stateProvider
.state('main.tabs', {
url: '/tabs',
views: {
'main': {
templateUrl: './app/tabs/tabs.html',
controller: 'TabsCtrl'
}
}
});
// This is not called, I don't see the trace in the logs
console.log($stateProvider);
});
dashboard.js
var dashboard = angular.module('dashboard', ['models.dashboards', 'main']);
dashboard.config(function ($stateProvider) {
$stateProvider
.state('main.dashboard', {
url: "/dashboard",
views: {
'main': {
resolve: {
'dashboard': ['DashboardService', function (DashboardService) {
return DashboardService.getInstance();
}]
},
templateUrl: "./app/dashboard/dashboard.html",
controller: 'DashboardCtrl'
}
}
});
console.log($stateProvider);
});
修改:包含ui.router
app.js(离子与ui-router捆绑在一起)
angular.module('starter', ['ionic', 'restangular', 'dashboard', 'ngCordova', 'LocalStorageModule', 'services.auth'])
来自离子源:
var IonicModule = angular.module('ionic', ['ngAnimate', 'ngSanitize', 'ui.router']),
来自index.html的 ng-app
指令
<body ng-app="starter">
<ion-nav-view></ion-nav-view>
</body>
答案 0 :(得分:1)
您的应用是starter
模块。 starter
取决于dashboard
。 dashboard
取决于main
。这些模块都不依赖于tabs
。因此未加载tabs
模块。