我有一个工厂方法作为..
(function (angular) {
"use strict";
angular
.module('app')
.factory('UserService', ['$rootScope', '$q', function ($rootScope, $q) {
var markCurrentUserAsContentOwner = function () {
var user = getCurrentUser(true);
user.set('isContentOwner',"true");
user.save(null, {
success: function(savedUser) {
alert("succes");
},
error: function(savedUser,error) {
alert("error");
}
});
};
}]);
})(angular);
现在如果我从另一个服务方法调用这个方法..
(function(angular) {
'use strict';
angular
.module('app')
.service('ContentOwnerService',
[
'$q', 'UserService'
function($q, userService) {
var servicemethod=function() {
userService.markCurrentUserAsContentOwner();//UserService is the factory name
};
}]);
})(angular);
它显示一个错误..Uncaught TypeError: undefined is not a function。请任何人帮助我解决此错误..