December 26, 2015

AngularJs how to sum two dynamic value from text box?



- Please write following function in script file for sum two dynamic value from text box,

angular.module('App').filter('twosum', function() {
  return function(items) {
    var sum = 0;
    items.forEach(function(item) {
      if (item.item_count) {
         sum += item.item_count;    
      }
    })
    return sum;
  }
})

- In HTML/PHP file where you want to display above sum value write below short code,

<span>{{ table.fields | twosum }}</span>

Enjoy!

1 comment:

  1. Excellent post. It is very inspiring and informative. Thank you for sharing this
    Web Design Company Kerala

    ReplyDelete

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...