我想将变量传递给我的工厂,但我不太清楚如何做,这是我的代码:
var app = angular.module('docFinder', []);
app.factory('docFactory', function($http) {
var url = 'http://test.example.com?queryString=searchv2&page=';
url=url+page;
var docFactory = {
async: function() {
var promise = $http.get(url).then(function (response) {
return response.data;
});
return promise;
}
};
return docFactory;
});
app.controller('docTable', function(docFactory, $scope, $filter) {
docFactory.async().then(function(d) {
$scope.providers = d;
init();
});
Run Code Online (Sandbox Code Playgroud)
}
我想将页面从我的控制器发送到我的工厂,以便它可以返回我的新查询
谢谢
rGi*_*Gil 13
您可以通过async
工厂中的函数传递值:
var docFactory = {
async: function(theVarThatIWantedToPass) {
var url=// stuff
url += theVarThatIWantedToPass;
}
}
Run Code Online (Sandbox Code Playgroud)
被称为正常:docFactory.async(页面)
归档时间: |
|
查看次数: |
12713 次 |
最近记录: |