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

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...