Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 11a3fd2

Browse files
committed
Merge pull request #311 from thgreasi/scoped
feat(sortable): add scope isolation
2 parents a257a20 + 36a14c3 commit 11a3fd2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/sortable.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ angular.module('ui.sortable', [])
1010
function(uiSortableConfig, $timeout, $log) {
1111
return {
1212
require: '?ngModel',
13+
scope: {
14+
ngModel: '=ngModel',
15+
uiSortable: '=uiSortable'
16+
},
1317
link: function(scope, element, attrs, ngModel) {
1418
var savedNodes;
1519

@@ -56,7 +60,7 @@ angular.module('ui.sortable', [])
5660
helper: null
5761
};
5862

59-
angular.extend(opts, directiveOpts, uiSortableConfig, scope.$eval(attrs.uiSortable));
63+
angular.extend(opts, directiveOpts, uiSortableConfig, scope.uiSortable);
6064

6165
if (!angular.element.fn || !angular.element.fn.jquery) {
6266
$log.error('ui.sortable: jQuery should be included before AngularJS!');
@@ -67,7 +71,7 @@ angular.module('ui.sortable', [])
6771

6872
// When we add or remove elements, we need the sortable to 'refresh'
6973
// so it can find the new/removed elements.
70-
scope.$watch(attrs.ngModel+'.length', function() {
74+
scope.$watch('ngModel.length', function() {
7175
// Timeout to let ng-repeat modify the DOM
7276
$timeout(function() {
7377
// ensure that the jquery-ui-sortable widget instance
@@ -256,7 +260,7 @@ angular.module('ui.sortable', [])
256260
return inner;
257261
};
258262

259-
scope.$watch(attrs.uiSortable, function(newVal /*, oldVal*/) {
263+
scope.$watch('uiSortable', function(newVal /*, oldVal*/) {
260264
// ensure that the jquery-ui-sortable widget instance
261265
// is still bound to the directive's element
262266
if (!!element.data('ui-sortable')) {

0 commit comments

Comments
 (0)