'use strict';
angular.module('confusionApp', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
// route for the home page
.state('app', {
url:'/',
views: {
'header': {
templateUrl : 'views/header.html'
},
'content': {
template : '<h1>To be Completed</h1>',
controller : 'IndexController'
},
'footer': {
templateUrl : 'views/footer.html'
}
}
})
// route for the aboutus page
.state('app.aboutus', {
url:'aboutus',
views: {
'content@': {
template: '<h1>To be Completed</h1>'
}
}
})
// route for the contactus page
.state('app.contactus', {
url:'contactus',
views: {
'content@': {
templateUrl : 'views/contactus.html',
controller : 'ContactController'
}
}
})
// route for the menu page
.state('app.menu', {
url: 'menu',
views: {
'content@': {
templateUrl : 'views/menu.html',
controller : 'MenuController'
}
}
})
// route for the dishdetail page
.state('app.dishdetails', {
url: 'menu/:id',
views: {
'content@': {
templateUrl : 'views/dishdetail.html',
controller : 'DishDetailController'
}
}
});
$urlRouterProvider.otherwise('/');
});
对于我尝试使用 UI-Router 的 app.js 文件,我使用 Bower 来安装 UI-Router 的 Angular 依赖项。当我将它们包含在标签中时,它们当前具有正确的路径。我检查以确保这些文件也位于 Bower_components 文件内。然而,当我运行该程序时,没有任何显示,我收到的唯一错误是“ Uncaught Error :[$injector:modulerr]”错误。
最佳答案
似乎 Angular 找不到 ui-route 模块, 请记住将其包含在您的 html 中。使用类似的东西
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-ui-router/angular-ui-router.js"></script>
如果您使用 bower 。
对不起,我的英语。我希望这对您有用。
关于javascript - 尝试注入(inject) UI-Router 时收到 "injector:modulerr"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41882208/