我正在使用angularjs,在尝试了ngRoute并观看了关于角度路由的多个视频的几个课程后,我尝试使用ui.router制作一个小项目
(function(){
var myApp = angular.module('myApp',['ui.router']);
myApp.config(['$stateProvider','$locationProvider',function($stateProvider,$locationProvider){
$locationProvider.html5mode(true);
$stateProvider.state('home',{
url:'/',
templateUrl:'views/home.html',
controller:'homeController',
controllerAs:'home',
resolve:{
controller:['$q',function(){
var defer = $q.defer();
require([],function(){
defer.resolve();
});
return defer.promise;
}]
}
}).state('login',{
url:'/login',
templateUrl:'views/login.html',
controller:'loginController',
controllerAs:'login',
resolve:{
controller:['$q',function($q){
var defer = $q.defer();
resolve(['resources/js/sha512.js','controllers/login.js'],function(){
defer.resolve();
});
return defer.promise;
}]
}
}).state('parent.index',{ url:'' });
}]);
myApp.factory('sessionService',function(){
var session = {
status: false,
get status(){ return status; },
set status(nStatus){ status = nStatus;},
privilege:0,
get privilege(){ return privilege; },
set privilege(nPrivilege){ privilege = nPrivilege; }
}
return session;
});
}());
我的浏览器出现了一个时髦的错误,"错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.5/ $ injector / modulerr?p0 = superiorTech& p1 =%24locationProvider.html5mode%20is%20not%20a %20function%0A%40http%3A%2F"
我可以推断它意味着依赖注入器无法解析$ locationProvider,在阅读了角度的文档之后,我验证了$ locationProvider是角度核心模块的一部分所以它不应该是问题,还没有其他代码,所有其他文件都是空白的。