错误:错误:interr插值在anguler js中应用动态自定义过滤器时出错

时间:2014-11-06 10:31:20

标签: javascript angularjs tree treegrid

我正在使用树形网格(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

建议我哪里出错了。

treeGrid.js

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);
    }
}]);

树网格directive.js

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 */
      };
    }
  ]);

树网格template.html

<td ng-repeat="col in colDefinitions" >
    {{row.branch[col.field] | custom : treeGridTest.filterArray[col.field]}}
</td>

0 个答案:

没有答案