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;
};
No comments:
Post a Comment