所以我通过解析在我的路由器中做一个http请求,我想知道如何从我的http请求中的工厂获取值?我的工厂中有一个函数,我想调用它并从中获取一个值并通过 http 请求发送该值。有什么办法可以在解析函数中注入工厂吗?
$routeProvider
.when('/', {
redirectTo: '/home'
})
.when('/home', {
templateUrl: 'views/main_portal.html',
controller: MyController15,
resolve: MyController15.loadAll
})
.when('/home/convo', {
templateUrl: 'views/convo.html',
})
.otherwise({
redirectTo: '/home'
});
MyController15.loadAll = {
//I WANT TO PASS A VARIABLE HERE TO USE IN THE PARAMS OBJECT.
allQ: function($http) {
return $http({
url: some_url,
method: post,
params: {action: 'someAction', valueToPass: ???????}
});
}
};
var MyController15 = ['allQ',
function(allQ){
//some data manipulation of allQ.data
}];