gpt4 book ai didi

javascript - Angular 过滤器 "Error: [ngModel:nonassign] Expression ' (gridData.StructureViewModel | sumPlanByKpi :kpi )' is non-assignable."

转载 作者:行者123 更新时间:2023-11-30 09:42:58 25 4
gpt4 key购买 nike

请帮我解决这个错误。我做错了什么?

我有这个带有自定义过滤器的输入 | 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="{{' '}}">

IMAGE - And I get this errors on client

最佳答案

我找到了我的问题的答案。在这种情况下,我应该使用 ng-value 作为输入,而不是 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="{{' '}}">

关于javascript - Angular 过滤器 "Error: [ngModel:nonassign] Expression ' (gridData.StructureViewModel | sumPlanByKpi :kpi )' is non-assignable.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40258412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com