angularjs - How to evaluate a filter string programmatically in an Angular expression -
i'm trying evaluate filters programmatically within angular expression in template.
html:
<div ng-app="myapp"> <div ng-controller = "myctrl"> <div ng-grid="gridoptions" class="gridstyle"></div> </div> </div>
js:
var app = angular.module('myapp', ['nggrid']); app.controller('myctrl', function ($scope) { $scope.mydata = [{name: "moroni", age: 50}, {name: "tiancum", age: 43}, {name: "jacob", age: 43}, {name: "nephi", age: 29}, {name: "enos", age: 34}]; $scope.gridoptions = { data: 'mydata', columndefs: [{ field: "name", }, { field: "age", celltemplate: '<div><div>{{row.getproperty(col.field) | col.coldef.filter}}</div></div>', cellfilter: 'test' }], }; }); app.filter('test', function () { return function (input) { return input + '!'; }; });
css:
.gridstyle { border: 1px solid rgb(212, 212, 212); width: 100%; height: 500px; }
as can see, in celltemplate 'age' column, i'm trying pass through cell data through filter in string in column definitions (col.coldef.filter).
is possible?
i want because want use 1 template define variety of filters on each of columns.
how adding test
filter instead of getting col
's:
{{row.getproperty(col.field) | test}}
updated jsfiddle.
Comments
Post a Comment