1

/Hello.

.directive('rnDatatable', function($filter) { //Таблица

return {

    scope : {
        ngTablefields : "=",
        ngTabledata : "="
    },
    restrict: 'AEC',
    link: function(scope, element, attrs) {
         scope.ngOrderb = function(fld) {
             scope.OrderRev=!scope.OrderRev
            scope.ngTabledata = $filter('orderBy')(scope.ngTabledata, fld,scope.OrderRev);
        }
    },          

    template: 
            '<table class="table table-striped">'+
            '<tr>'+
            '<td  ng-repeat="fields in  ngTablefields">'+
            '<span class="text-primary pointer" ng-click="ngOrderb({fld:fields.colvalue})">   {{fields.colname}}   </span> </td>'+
            '</tr>'+
            '<tr ng-repeat="row in ngTabledata"  class="animate-if">'+
            '<td ng-repeat="fields in ngTablefields">'+
            '<span class="text-default "> {{row[fields.colvalue]}}</span>'+
            '</td>'+
            '</tr>'+
            '</table>'  



};

});

I have an error on $filter('orderBy')

TypeError: object is not a function

  • at Array. (/js/angular.js:15550:24)
  • at comparator (/js/angular.js:15559:36)
  • at /js/angular.js:15566:34
  • at Array.sort (native)
  • at /js/angular.js:15555:22
  • at Scope.scope.ngOrderb (/js/controller.js:371:43)
  • at /js/angular.js:10797:21
  • at /js/angular-touch.js:472:9
  • at Scope.$eval (/js/angular.js:12699:28)
  • at Scope.$apply (/js/angular.js:12797:23)

Could you please explain me why?

update: plunker

6
  • could you include an example for ngTablefields? This would help much to answer your question. Commented Sep 2, 2014 at 8:27
  • <rn-Datatable ng-Tablefields="psptablechngfields" ng-Tabledata="histpaspchanges" ></rn-Datatable> Commented Sep 2, 2014 at 8:36
  • [{"colname":"Дата изменения", "colvalue":"EdDateTime", "type":"date"}, {"colname":"Пользователь БД", "colvalue":"EdDBOperator", "type":"string"}, {"colname":"Оператор", "colvalue":"EdWSOperator", "type":"string"}, {"colname":"АРМ", "colvalue":"EdApplicationTitle", "type":"string"}, {"colname":"Рабочая станция", "colvalue":"EdWorkstation", "type":"string"}, {"colname":"Состояние", "colvalue":"FName", "type":"string"}] Commented Sep 2, 2014 at 8:38
  • could you also include an exampe for ngTabledata? Commented Sep 2, 2014 at 8:48
  • plnkr.co/edit/LY8HxCAgOAEExp4NSz7F?p=info Commented Sep 2, 2014 at 8:52

1 Answer 1

1

The problem isthe ng-click directive in your template. The solution is quite simple:

<span class="text-primary pointer" ng-click="ngOrderb(fields.colvalue)">

Your example in the plunkr works when you change that argument to fields.colvalue.

Sign up to request clarification or add additional context in comments.

1 Comment

thx. i found another way. $filter('orderBy')(scope.ngTabledata, fld.fld,scope.OrderRev);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.