如何访问节点JS的角度筛选值 [英] How to access the angular filter value in node js
本文介绍了如何访问节点JS的角度筛选值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图访问使用req.body这是NG的模式,其实我的NG-模型是有一个角的js过滤器节点JS的价值,我需要从输入字段的节点JS的筛选值使用req.body,我在这里贴上我的NG-模型code片段,请帮我解决。
<输入类型=禁用NG-禁用=真正的类=表格控
NAME =算NG模型=table.fields | mysum>
角过滤器
app.filter('mysum',函数(){
返回功能(项){
变种总和= 0;
items.forEach(函数(项目){
如果(item.item_count){
总和+ = item.item_count;
}
})
返回总和;
}
})
解决方案
这将是你的DOM,你不能使用过滤器,NG-模式。
<输入类型=禁用NG-禁用=真正的类=表格控
NAME =算NG模型=table.fields>
和在你的控制器code,做这样的事情。注 $过滤器
作为控制器的依赖。
$ scope.table = {};
$ scope.table.fields = $滤波器('mySum')($ scope.table.fields);//留意更新值...。
$范围。$腕表('table.fields',函数(){
//注意有无变化,做一些事情...
});
I am trying to access the value in node js using req.body which is in ng-model, actually my ng-model is having a angular js filter,I need to get that filter value from the input field in node js using req.body, I paste my ng-model code snippet here, please help me to resolve
<input type="disable" ng-disabled="true" class="form-control"
name="count" ng-model="table.fields | mysum">
angular 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;
}
})
解决方案
This would be your DOM, you can't apply filters to ng-model.
<input type="disable" ng-disabled="true" class="form-control"
name="count" ng-model="table.fields">
And in your controller code, do something like this. Inject $filter
as dependency in your controller.
$scope.table = {};
$scope.table.fields = $filter('mySum')($scope.table.fields);
//watch for updated value... .
$scope.$watch('table.fields', function() {
//watch for changes and do something...
});
这篇关于如何访问节点JS的角度筛选值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文