diff --git a/ng-sortable.js b/ng-sortable.js index c292791..19310fc 100644 --- a/ng-sortable.js +++ b/ng-sortable.js @@ -26,7 +26,8 @@ angular.module('ng-sortable', []) .constant('version', '0.3.7') - .directive('ngSortable', ['$parse', function ($parse) { + .constant('ngSortableConfig', {}) + .directive('ngSortable', ['$parse', 'ngSortableConfig', function ($parse, ngSortableConfig) { var removed, nextSibling; @@ -67,7 +68,7 @@ scope: { ngSortable: "=?" }, link: function (scope, $el, attrs) { var el = $el[0], - options = scope.ngSortable || {}, + options = angular.extend(scope.ngSortable || {}, ngSortableConfig), source = getSource(el), watchers = [], sortable diff --git a/st/app.js b/st/app.js index fe50fe9..164270d 100644 --- a/st/app.js +++ b/st/app.js @@ -148,6 +148,9 @@ // Angular example angular.module('todoApp', ['ng-sortable']) + .constant('ngSortableConfig', {onEnd: function() { + console.log('default onEnd()'); + }}) .controller('TodoController', ['$scope', function ($scope) { $scope.todos = [ {text: 'learn angular', done: true},