Waheed Mohammad Waheed Mohammad - 1 year ago 53
AngularJS Question

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

Here why my total amt not counting

<div ng-controller="MyHomeCNtrls">
<div id="CountdataWithinhTheDiv">
<tr ng-repeat="pr in Prodt">
<td>Total: {{ getTotal() }}</td>

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


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 Source

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;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download