我敢肯定这件事情简单,我在这里失踪,但我不能得到这个工作.. 我想用一个工厂,这样我可以重复使用多个控制器的数据。不能得到restangular工厂上班
(function() {
'use strict';
angular
.module('www')
.factory('profileFactory', profileFactory);
profileFactory.$inject = ['Restangular'];
/* @ngInject */
function profileFactory(Restangular) {
var service = {
getUserData: Restangular.one('/user/profile/').getList(),
getFriendList: Restangular.all('api/users/getfriendsinvitations/').getList()
};
return service;
}
})();
控制器:
(function() {
'use strict';
angular
.module('www')
.controller('ProfileController', ProfileController);
ProfileController.$inject = ['profileFactory'];
/* @ngInject */
function ProfileController() {
activate();
function activate(profileFactory, $scope) {
profileFactory.getFriendList.then(function (homeFriends) {
$scope.homeFriends = homeFriends;
});
}
}
})();
而且我不断收到 “类型错误:无法读取的未定义的属性 'getFriendList'”
编辑:我曾尝试为好,https://github.com/mgonto/restangular#decoupled-restangular-service,但没有运气!
请形成你的标题一个实际的问题。它看起来像标签。另外,请扩展您自己解决这个问题的努力。你检查过第一/第三方图书馆的文件吗? – onebree
你能提供一个plunker文件吗?我们需要知道另一个细节,例如:“您拨打服务的方式”等。 –