我正在使用树形网格(http://khan4019.github.io/tree-grid-directive/test/treeGrid.html)并基于列/标题类型应用相应的过滤器。我创建了自定义过滤器并应用于ng-repeat。
Can't interpolate: {{row.branch[col.field] | custom : treeGridTest.filterArray[col.field]}}
Error: [$injector:unpr] http://errors.angularjs.org/1.2.26/$injector/unpr?p0=undefinedFilterProvider%20%3C-%20undefinedFilter
建议我哪里出错了。
var app = angular.module('treeGridTest', ['treeGrid']);
app.controller('treeGridController', function($scope) {
$scope.filterArray = {
'Sales': 'currency',
'Profit': 'currency',
'Area' : 'lowercase'
};
});
app.filter('custom', ['$filter', function (segmentio) {
return function (value, type) {
return segmentio(type)(value);
}
}]);
var module = angular.module('treeGrid',[]);
module.directive('treeGrid', [
'$timeout', function($timeout) {
return {
restrict: 'E',
templateUrl:'tree-grid-template.html',
replace: true,
scope: {
treeData: '=',
colDefs:'=',
expandOn:'=',
onSelect: '&',
initialSelection: '@',
treeControl: '='
},
link: function(scope, element, attrs) {
/* Some code */
};
}
]);
<td ng-repeat="col in colDefinitions" >
{{row.branch[col.field] | custom : treeGridTest.filterArray[col.field]}}
</td>