Pls, help me resolve this error. And what i do wrong?
I have this INPUT with custom filter | sumPlanByKpi:kpi
filterModule.filter('sumPlanByKpi', ['$filter', function ($filter) {
return function (input, kpi) {
if (angular.isUndefined(input) && angular.isUndefined(kpi))
return 0;
var sum = 0;
var findedPlansArray = [];
for (i = 0; i < input.length; i++) {
var findedPlans = $filter('filter')(input[i].Plans, function (plan) { return plan.KPI_ID === kpi.ID; });
var temp = findedPlansArray.concat(findedPlans);
findedPlansArray = temp;
}
angular.forEach(findedPlansArray, function (v, k) {
if (v.Value != null)
sum = sum + parseInt(v.Value);
});
return sum;
};
}]);
<input type="text" class="form-control input-sm col-lg-1" ng-model="(gridData.StructureViewModel | sumPlanByKpi:kpi)"
disabled="" pattern="^[0-9]*$" min="0" max="1e+22" step="1"
awnum num-sep=',' num-neg=false num-int=40 num-fract=0 num-thousand=true num-thousand-sep="{{' '}}">
I find answer for my question. I should use ng-value for input in this case instead of ng-model.
<input type="text" class="form-control input-sm col-lg-1" ng-value="(gridData.StructureViewModel | sumPlanByKpi:kpi)"
disabled="" pattern="^[0-9]*$" min="0" max="1e+22" step="1"
awnum num-sep=',' num-neg=false num-int=40 num-fract=0 num-thousand=true num-thousand-sep="{{' '}}">