我的应用程序配置:angularJS - 我的服务不叫得到错误
(function(){
"use strict";
angular.module("blog", ["ngRoute", "blog.controllers", "blog.services" ]);
function config ($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: 'modules/users/views/users-list.tpl.html',
controller: 'User.controller',
controllerAs: 'userlist'
});
}
angular
.module('blog')
.config(config);
})();
我的服务:
(function(){
"use strict";
angular.module("blog.services", ["ngResource"])
.service("userService", function() {
console.log("service called");
this.name = function() {
// return $resource(BaseUrl + ‘/posts/:postId’, { postId: ‘@_id’ });
return "Tech Mahindra";
}
})
})();
我的控制器:
(function(){
"use strict";
angular.module("blog.controllers", [ "userService" ])
.controller("User.controller", function( service) {
var userlist = this;
userlist.name = "Nissan New Japan!!";
console.log("user controller ready!!");
console.log("from service post : " , service.name()); //throws error
return userlist;
});
})();
这里有什么问题?任何一个帮助我?
错误我得到:
Uncaught Error: [$injector:modulerr] Failed to instantiate module blog due to:
Error: [$injector:modulerr] Failed to instantiate module blog.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module userService due to:
Error: [$injector:nomod] Module 'userService' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
你可以张贴错误? –