Skip to content

Commit

Permalink
ng-sortable: support configuration constant
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris committed May 30, 2015
1 parent 851129a commit f33927b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ng-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions st/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit f33927b

Please sign in to comment.