0
剛開始使用AngularJS。我不確定如何把這個搞混。我試圖在一個服務中包含多個功能。 (我希望這不是對不好的做法。)如何在AngularJS的服務中編寫多個Aync功能
以下是我的工作代碼:
myDataService.async().then(function (d) {
$scope.dbCalls = d.d;
});
我的服務:
app.factory('myDataService', function ($http) {
// How do you get this bottom line to work?
// this.getAllCalls = function() {
var myService = {
async: function() {
var promise = $http.post('AngularTest.aspx/FetchCalls', { data: {} }).then(function (response) {
console.log(response);
return response.data;
});
return promise;
}
};
return myService;
//}; <--Commented out for clarity
});
謝謝!
精彩!!!這工作!謝謝! – InCode