UIで更新された金額を取得できませんでしたが、ネットワークを調べると応答値が確認できました。私のコードに何か問題がありますか?私は$ resourceに精通しておらず、angularjsにはまったく新しいものです。
<ion-view title="HSF" id="page4">
<ion-content overflow-scroll="true" padding="true" class="has-header">
<h3 id="hSF-heading5" style="color:#000000;text-align:center;">Summary</h3>
<ion-scroll>
<ul class="list" data-ng-repeat="mth in monthList()">
<li class="item item-positive" ng-click="">
{{mth.label}}
<span style="float: right;">Total: ${{mth.amount}}</span>
</li>
</ul>
</ion-scroll>
</ion-content>
</ion-view>
.factory('RESTService',['$resource', function($resource){
return $resource('http://xxx/' + 'transaction', {id: '@id'},{
readSales: {
method: 'POST',
isArray: false
}
});
}])
.controller('HSFCtrl', function($scope, $http, $state, RESTService) {
//region YearlySales
var list = [];
var today = new Date();
var yearIndex = today.getFullYear();
var yearObj = {
label: "",
amount:0
};
yearObj.label = yearIndex;
$http({
url: 'http://xxx/' + 'transaction',
data: {"type": 3, "datetime": yearObj.label},
method: 'POST'
}).success(function (response) {
yearObj.amount = response;
});
list.push(yearObj);
$scope.yearList = list;
//endregion
//region MonthlySales
$scope.monthList = [];
var months = [1,2,3,4,5,6,7,8,9,10,11,12,13];
var monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December' ];
for(var mth in months){
$scope.amount = {};
var monthObj = {
label: "",
amount: 0
};
var objToSend = {
type: 2,
datetime: '2016' + '-' + mth
};
//console.log(mth);
var read = RESTService.readSales(objToSend);
read.$promise.then(function(result){
monthObj.amount = Number(result);
});
monthObj.label = monthNames[mth];
$scope.monthList.push(monthObj);
}
//console.log($scope.monthList);
//endregion
$scope.goToMSP = function(){
$state.go('tabsController.MSP');
}
});