I get the error
Unknown provider: $userProvider <- $user"
With following code:
var app = angular.module('test', []);
app.factory("user", function($scope, $http) {
var usr = {};
usr.getAllLists = function(){
return "test";
}
return usr;
});
cart.controller("MyController", ["$scope", "$http", "$user",
function ($scope, $http, user){
$scope.initialize = function(){
$scope.lists = user.getAllLists();
}
}
]);
Do you see the mistake?
I get the error
Unknown provider: $userProvider <- $user"
With following code:
var app = angular.module('test', []);
app.factory("user", function($scope, $http) {
var usr = {};
usr.getAllLists = function(){
return "test";
}
return usr;
});
cart.controller("MyController", ["$scope", "$http", "$user",
function ($scope, $http, user){
$scope.initialize = function(){
$scope.lists = user.getAllLists();
}
}
]);
Do you see the mistake?
Share Improve this question edited Mar 3, 2016 at 15:14 JEuvin 1,0381 gold badge15 silver badges32 bronze badges asked Jun 11, 2015 at 22:30 sibe94sibe94 1351 gold badge3 silver badges10 bronze badges1 Answer
Reset to default 6Assuming cart is having dependency on app module.
cart.controller("MyController", ["$scope", "$http", "user",
function ($scope, $http, user){
$scope.initialize = function(){
$scope.lists = user.getAllLists();
}
}
It has to be user and not $user
.
Also, in factory, in place of $scope
, use $rootScope
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745569540a4633597.html
评论列表(0条)