user2563380
user2563380

Reputation: 1

getting:Error: ngModel:nonassign Non-Assignable Expression

I have created a filter to calculate sum of the input values inside ng-repeat and am accessing that filter outside the ng-repeat am getting the error as :Error: ngModel:nonassign Non-Assignable Expression how do I resolve it, below is my code

**HTML**
     <input type="disable" ng-disabled="true" class="form-control"  name="count" ng-model="table.fields | mysum">

**Angularjs Filter**

      app.filter('mysum', function() {
  return function(items) {
    var sum = 0;
    items.forEach(function(item) {
     if (item.item_count) {
         sum += item.item_count;      
      }     
    })
    return sum;
  }
})

Upvotes: 0

Views: 2782

Answers (1)

datasage
datasage

Reputation: 19563

ng-model is a two way binding. What you are trying to do is bind it to a filter output. Which is not supported.

Instead use this value="{{table.fields | mysum}}"

Upvotes: 3

Related Questions