我正在使用过滤器来计算值,但随后我想稍后再访问它们。AngularJS - 无法使用过滤器设置视图中的变量
这里是我的代码片段:
app.controller('CreateProposalCtrl', function() {
$scope.EstimatedCostItem = [];
});
-
app.filter('EstimatedValue', function() {
return function(input, arguments) {
...blah blah calculations
return calculations;
};
});
我不知道该如何HTML应提交。
这显示正是我want..BUT我需要它来设置一个变量,所以我可以访问它在其他地方..
<span ng-repeat="foo in bar">
{{ Type.JobTypeID | EstimatedValue: form }}
</span>
我已经试过:
<span ng-model="EstimatedCostItem[Type.JobTypeID]" ng-bind="Type.JobTypeID | EstimatedValue: form"></span>
和:
<span ng-bind="EstimatedCostItem[Type.JobTypeID]">{{ Type.JobTypeID | EstimatedValue: form }}</span>
和:
<span ng-init="EstimatedCostItem[Type.JobTypeID] = (Type.JobTypeID | EstimatedValue: form)"></span>
似乎没有设置变量。我难倒:(
您何时需要设置变量? –