我尝试使用以下代码过滤列:
JS:
$scope.filter = {};
$scope.filterColumn = function (propName) {
$scope.informsystemList = EntityManager.query({entity: "informsystem",propName:$scope.filter[propName]});
}
HTML:
<input type="text" ng-model="filter.name" ng-change="filterColumn('name')">
资源:
portalApp.factory("EntityManager", function ($resource) {
return $resource("rest/:treeNodeType/:entity/:id", {treeNodeType:'@treeNodeType',entity: '@entity', id: '@id'},
{
update: {
method: 'PUT'
}
});
});
问题在propName:$scope.filter[propName]
中 - 参数值是正常的,但参数名称不是变量值,而是&#34; propName&#34;。如何解决这个问题?
答案 0 :(得分:1)
因此,如果您想使用propName值作为属性名称,则必须这样做:
$scope.filterColumn = function (propName) {
var data = {entity: "informsystem"};
data[propName] = $scope.filter[propName];
$scope.informsystemList = EntityManager.query(data);
}