Tuesday 11 June 2019

Here im Using AngularJs when my data in div why my total amout not counting



Here why my total amt not counting























Id Name Quentity Price Total
{{pr.productId}} {{pr.ProductName}} {{pr.quantity}} {{pr.Price}} {{pr.Total}} Total: {{ getTotal() }}






AngularCode
Service
this.Gymser = function () {
var xx = $http({ url: '/Home/Prodt', method: 'Get',params: JSON.stringify(),
content: { 'content-type': 'application/Json' } }) return xx;}



controller




 function PropertyData() {
var xxx = Myservice.Gymser();
xxx.then(function (d) {
$scope.Prodt = d.data;
})
}


AngularCode For Counting




 $scope.getTotal = function () {
var total = 0;for (var i = 0; i < $scope.Products.length; i++) {
var product = $scope.Products[i];total += (Product.price * Product.quantity);}return total;}

Answer



I do not see your controller having Function named getTotal()



You should have defined in the controller,




   $scope.getTotal = function(type) {
var total = 0;
angular.forEach($scope.items, function(el) {
total += el[type];
});
return total;
};


DEMO



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...