%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/public/scripts/directives/
Upload File :
Create Path :
Current File : /var/www/html/news/public/scripts/directives/sortData.js

'use strict';

angular.module('directives').directive('sortData', function (resource) {
    return {
        restrict: 'A',
        scope: {
            title: "@sortTitle",
            property: "@property",
            direction: "@direction",
            search: "&search"
        },
        template: '<a class="sort-data" ng-click="sort()">' +
        '<span>{{title}}</span>' +
        '<span class="fa pull-right" ng-class="{\'fa-caret-up\': direction === \'asc\', \'fa-caret-down\': direction === \'desc\'}"></span>' +
        '</a>',
        link: function (scope) {
            scope.sort = function () {
                scope.direction = !scope.direction ? 'asc' : scope.direction === 'desc' ? null : 'desc';
                resource.setOrderBy({
                    property: scope.property,
                    direction: scope.direction
                });
                scope.search();
            };
        }
    };
});

Zerion Mini Shell 1.0