angularjs的依赖注入
我想向config中注入自定义provider,请问怎么注入
myApp.provider('test',function(){
this.$get = function(){
return {
test:alert("23")
};
}
});
myApp.config(['$routeProvider','$httpProvider',function($routeProvider,$httpProvider,testProvider) {
$routeProvider.otherwise({
redirectTo: '/home'
});
testProvider.test;
routeProvider = $routeProvider;
$httpProvider.interceptors.push('httpInterceptor');
}]);
提示错误
angular.min.js?v=:6 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=myApp&p1=TypeError%…%3A8080%2Fcom%2Fresources%2Fjs%2Fangular%2Fangular.min.js%3Fv%3D%3A19%3A83)
at angular.min.js?v=:6
at angular.min.js?v=:38
at n (angular.min.js?v=:7)
at g (angular.min.js?v=:37)
at eb (angular.min.js?v=:41)
at c (angular.min.js?v=:19)
at yc (angular.min.js?v=:20)
at Zd (angular.min.js?v=:19)
at HTMLDocument.<anonymous> (angular.min.js?v=:294)
at j (jquery-1.11.1.min.js?v=:2)