Would like to automatically update the div using $scope.push
encountering an issue:
Error: Cannot read property 'push' of undefined
Here are my JSON and JavaScript snippets:
JSON
{"records":[{"total":"156000"}]}
JavaScript
$scope.plusCart = function() {
$http({
method : 'POST',
url : 'http://localhost/so-ku/www/server/menu/plus_cart',
headers : { 'Content-Type' : 'application/json' },
data : JSON.stringify({ rowid: $scope.currentItem.rowid, qty : $scope.currentItem.qty })
}).success(function(data) {
total_cart()
});
}
function total_cart() {
$http.get('http://localhost/so-ku/www/server/menu/total_cart').
then(function(response){
$scope.x = [];
$scope.x = response.data.records;
$scope.xtotal.push($scope.x.total);
});
}
html
<div ng-controller="CartCtrl">
<div ng-repeat="tot in xtotal" style="padding-top: 10px;">
Rp {{tot.total}}
</div>
</div>
Note : Seeking to have the div content automatically updated after submitting plusCart with $scope.push
Many thanks.