Open brennancheung opened 9 years ago
When items is undefined at the time the template is loaded the directive does not work.
items
This is very common when the items are populated from a REST API call.
Ex:
In controller: setTimeout(function(){ $scope.items = [1,2,3]; }, 5000);
setTimeout(function(){ $scope.items = [1,2,3]; }, 5000);
In HTML: <div ng-sortable="items">...</div>
<div ng-sortable="items">...</div>
ng-sortable should implement a $watch for the $scope.ngSortable and only run the current linking code when it is defined and an array.
$watch
$scope.ngSortable
link
Please make a pull request. It would be appreciated, by me and others :)
When
items
is undefined at the time the template is loaded the directive does not work.This is very common when the items are populated from a REST API call.
Ex:
In controller:
setTimeout(function(){ $scope.items = [1,2,3]; }, 5000);
In HTML:
<div ng-sortable="items">...</div>
ng-sortable should implement a
$watch
for the$scope.ngSortable
and only run the currentlink
ing code when it is defined and an array.