Angularjs error Unknown provider: $ scopeProvider <- $ scope <- user
I am getting the error
Unknown provider: $ userProvider <- $ user "
With the 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 error?
+3
source share
1 answer
The intended cart has a dependency on the application module.
cart.controller("MyController", ["$scope", "$http", "user", function ($scope, $http, user){ $scope.initialize = function(){ $scope.lists = user.getAllLists(); } }
It should be a user, not $user
.
Also, in factory, $scope
use instead $rootScope
.
+5
source share