最初,我制作了一个控制器来为我保存数据,它对我有用。然后我把我的数据搬到了一家工厂。我将我的工厂注入控制器。我还将我的模块/控制器/工厂的地址放在我的 HTML 代码中,但我收到“未知提供者”的错误
这是我的工厂代码:
(function() {
var userFactory = function () {
user =
{
"objectId": "NlPjdF5yK2",
"username": "saberi.ar.eng@gmail.com",
"emailVerified": "true",
"email": "saberi.ar.eng@gmail.com",
"myOwnCards": "['zIlHxyotrV','i1OOfskc9p','pv3NeClPkb','sdNuOoa7L2']",
"name": "Alireza",
"profile": "Ali",
"surname": "Saberi",
"image": "../assests/images/people/NlPjdF5yK2.jpg"
};
var factory = {};
factory.getUser = function(){
return user;
};
return factory;
};
angular.module('ccApp').factory('userFactory', userFactory);
}());
这是我的控制器 condes
(function() {
var userController = function ($scope,userFactory) {
user = {};
function init(){
$scope.user = user;
};
init();
};
userController.$inject = ['$scope','userFactory'];
angular.module('ccApp').controller('userController', userController);
}());