私は次のようなことをしようとしています: 私のコントローラーには、データベースからデータを取得するために $recourse 呼び出しを使用する関数があります。サービス「myService」
var fillSubData = function (containerToFill) {
resService.getSubDataFromDB(//$resource service
{params},
function (res) {
//do something with containerToFill with the result res add new values
}
);
}
var fillData = function (containerToFill) {
resService.getDataFromDB(//$resource service
{params},
function (res) {
//do something with containerToFill with the result res
fillSubData(containerToFill);
}
);
}
コントローラ
$scope.dataToFill;// object
var initialize = function () {
//by reference
myService.fillData(dataToFill);
// I need the dataToFill filled to do other thing with data recovered and built
angular.forEach(dataToFill.someArrayBuilt, function (item) {
//do something with item...
})
}
復元および構築されたデータで他のことを行うために、dataToFill を埋める必要がありますが、リソース呼び出しは非同期です。これを行うにはどうすればよいですか?