Skip to content

Commit c62b986

Browse files
Portugal, Marcelomportuga
Portugal, Marcelo
authored andcommitted
fix(ui-grid.js): gridOptions.data string value now works again.
Added back if statement in the dataWatchFunction and added an $eval to ensure controllerAs systax is supported. fix #6377, fix #6155
1 parent 2f001f1 commit c62b986

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

misc/tutorial/106_binding.ngdoc

+10-8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ For better performance with the following example, you can choose to load the ui
2828
app.controller('MainCtrl', function MainCtrl() {
2929
var vm = this;
3030

31+
vm.myData = [
32+
{
33+
'first-name': 'Cox',
34+
friends: ['friend0'],
35+
address: {street: '301 Dove Ave', city: 'Laurel', zip: '39565'},
36+
getZip: function() {return this.address.zip;}
37+
}
38+
];
39+
3140
vm.gridOptions = {
3241
enableSorting: true,
3342
columnDefs: [
@@ -36,14 +45,7 @@ For better performance with the following example, you can choose to load the ui
3645
{ name:'city', field: 'address.city'},
3746
{ name:'getZip', field: 'getZip()', enableCellEdit: false}
3847
],
39-
data: [
40-
{
41-
'first-name': 'Cox',
42-
friends: ['friend0'],
43-
address: {street: '301 Dove Ave', city: 'Laurel', zip: '39565'},
44-
getZip: function() {return this.address.zip;}
45-
}
46-
]
48+
data: '$ctrl.myData'
4749
};
4850
});
4951
</file>

src/js/core/directives/ui-grid.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@
8484
// gridUtil.logDebug('dataWatch fired');
8585
var promises = [];
8686

87-
if (angular.isString($scope.uiGrid.data)) {
88-
newData = self.grid.appScope[$scope.uiGrid.data];
89-
} else {
90-
newData = $scope.uiGrid.data;
87+
if ( self.grid.options.fastWatch ) {
88+
if (angular.isString($scope.uiGrid.data)) {
89+
newData = self.grid.appScope.$eval($scope.uiGrid.data);
90+
} else {
91+
newData = $scope.uiGrid.data;
92+
}
9193
}
9294

9395
mostRecentData = newData;

0 commit comments

Comments
 (0)