Skip to content

Commit cc71080

Browse files
author
Eugene Draitsev
committed
Promises bug fix.
1 parent 11ef4e9 commit cc71080

File tree

4 files changed

+32
-22
lines changed

4 files changed

+32
-22
lines changed

dist/dataGrid.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ angular
3434

3535
$scope.$watch('_gridOptions.data', function (newValue) {
3636
if (newValue && newValue.length) {
37+
$scope.filtered = angular.copy($scope._gridOptions.data);
3738
if ($scope.urlSync) {
3839
parseUrl($location.path());
3940
} else {
@@ -61,7 +62,9 @@ angular
6162
clearTimeout($scope.getDataTimeout);
6263
$scope.getDataTimeout = setTimeout(getData, $scope.getDataDelay);
6364
}
64-
parseUrl($location.path());
65+
if ($scope.filtered) {
66+
parseUrl($location.path());
67+
}
6568
}
6669
});
6770

@@ -310,15 +313,17 @@ angular
310313

311314
function generateOptions(values, predicate) {
312315
var array = [];
313-
values.forEach(function (item) {
314-
if (!~array.indexOf(item[predicate])) {
315-
array.push(item[predicate]);
316-
}
317-
});
318-
319-
return array.map(function (option) {
320-
return {text: option, value: option};
321-
});
316+
if (values) {
317+
values.forEach(function (item) {
318+
if (!~array.indexOf(item[predicate])) {
319+
array.push(item[predicate]);
320+
}
321+
});
322+
323+
return array.map(function (option) {
324+
return {text: option, value: option};
325+
});
326+
}
322327
}
323328
}
324329
}

dist/dataGrid.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="container">
1313
<h1>Angular Data Grid</h1>
1414

15-
<div class="row" ng-if="dataLoaded">
15+
<div class="row">
1616
<div class="col-xs-12">
1717
<div class="col-md-3">
1818
<div class="form-group">

src/js/dataGrid.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ angular
3434

3535
$scope.$watch('_gridOptions.data', function (newValue) {
3636
if (newValue && newValue.length) {
37+
$scope.filtered = angular.copy($scope._gridOptions.data);
3738
if ($scope.urlSync) {
3839
parseUrl($location.path());
3940
} else {
@@ -61,7 +62,9 @@ angular
6162
clearTimeout($scope.getDataTimeout);
6263
$scope.getDataTimeout = setTimeout(getData, $scope.getDataDelay);
6364
}
64-
parseUrl($location.path());
65+
if ($scope.filtered) {
66+
parseUrl($location.path());
67+
}
6568
}
6669
});
6770

@@ -310,15 +313,17 @@ angular
310313

311314
function generateOptions(values, predicate) {
312315
var array = [];
313-
values.forEach(function (item) {
314-
if (!~array.indexOf(item[predicate])) {
315-
array.push(item[predicate]);
316-
}
317-
});
318-
319-
return array.map(function (option) {
320-
return {text: option, value: option};
321-
});
316+
if (values) {
317+
values.forEach(function (item) {
318+
if (!~array.indexOf(item[predicate])) {
319+
array.push(item[predicate]);
320+
}
321+
});
322+
323+
return array.map(function (option) {
324+
return {text: option, value: option};
325+
});
326+
}
322327
}
323328
}
324329
}

0 commit comments

Comments
 (0)