我创建了一个新项目,但遇到了一个无法解决的问题。
这是我的例子:
angular.module('MosysTimes', ['ngRoute']).config($routeProvider, RouteConfiguration);
function RouteConfiguration ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'start.html',
controller: 'WelcomeController'
})
.when('/login', {
templateUrl: 'login.html',
controller: 'LoginController'
})
.otherwise({
redirectTo: '/'
});
}
它总是说:
$routeProvider is undefined....
如有任何帮助,我们将不胜感激?
最佳答案
您应该将代码更改为此。
angular.module('MosysTimes', ['ngRoute']).config(['$routeProvider',function($routeProvider)
{
$routeProvider
.when('/', {
templateUrl: 'start.html',
controller: 'WelcomeController'
})
.when('/login', {
templateUrl: 'login.html',
controller: 'LoginController'
})
.otherwise({
redirectTo: '/'
});
}]);
关于angularjs - $routeProvider 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38157342/