0
から返された私は、以下の方法で取得しています。この配列を持っています。 http post urlメソッドを使用して別のurlにポストします。私が悩んでいるのは、非同期呼び出しのコンセプトです。そのため、お気に入りの番号リストを取得して編集できるようにはなりません。助けてください!Angularjsは編集アレイは、HTTP GET URL
次のように私は約束を使用する方法を試してみました:「が定義されていないD」
angular.module('JuryApp').controller('mycontroller', ['myService', function (myService) {
myService.async(url).then(function(d) {
$scope.data = d;
});
app.controller('MainCtrl', function(myService,$scope) {
// Call the async method and then do stuff with what is returned inside our own then function
myService.async().then(function(d) {
$scope.data = d;
});
});
をしかし、私はエラーを取得しておいてください。私がやっている私のコントローラで
app.factory('myService', function($http) {
var myService = {
async: function(url) {
var promise = $http.get(url).then(function (response) {
console.log(response);
return response.data;
});
// Return the promise to the controller
return promise;
}
};
return myService;
});
を。デバッガが無限ループや何かに入る何らかのエラーが発生し続けます。