1

I have an angular directive that sorts columns in a table. prior to version 1.20 this worked but after upgrading to 1.20 I am getting the following error. Does anyone know what is wrong?

Error: [$parse:isecprv] http://errors.angularjs.org/undefined/$parse/isecprv?p0=_sort()

app.directive('sorted', function () {
    return {
        scope: true,
        transclude: true,
        template: '<a href="#/" ng-click="_sort()" ng-transclude=""></a>' +
            '<span class="sortArrow" ng-show="show_sort_icon(true)">&#x25BC;</span>' +
            '<span class="sortArrow" ng-show="show_sort_icon(false)">&#x25B2;</span>',
        controller: function ($scope, $element, $attrs) {

            $scope._sort = function () {
                $scope.model.sort($attrs.sorted);
            };

            $scope.show_sort_icon = function (is_desc) {
                return ($scope.model.sidx == $attrs.sorted) && ($scope.model.is_desc == is_desc);
            };
        }
    };
});

Usage:

<table>
    <thead>
        <tr>
            <th sorted="something">Something</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="item in model.items">
            <td>{{item.something}}</td>
        </tr>
    </tbody>
</table>

enter image description here

8
  • can you reproduce this error in Plunker/Fiddle? Commented Nov 15, 2013 at 8:34
  • @MaximShoustin i'll try and post back. Commented Nov 15, 2013 at 8:35
  • Please provide a jsfiddle. One question: Why you dont use the orderBy Filter? What is the advantage Commented Nov 15, 2013 at 8:40
  • Thanks guys not sure what the problem was but in trying to reproduce in fiddle i found 1.2.1 works fine. Commented Nov 15, 2013 at 8:47
  • PS - the reason i need to filter on the server is because the client receives a subset of the full results. sorting needs to occur on the full set. Commented Nov 15, 2013 at 8:52

1 Answer 1

0

Answer found by @Heikki

Fields with names that begin or end with an underscore are considered private fields. Angular expressions are not allowed to reference such fields on the scope chain. This only applies to Angular expressions (e.g. interpolation and calls to $parse with a string expression argument) – Javascript itself has no such notion.

To resolve this error, use an alternate non-private field if available or make the field public (by removing any leading and trailing underscore characters from its name.)

Example expression that would result in this error:

<div>{{user._private_field}}</div>
Sign up to request clarification or add additional context in comments.

Comments

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.