Skip to content

Commit

Permalink
fix(ui-grid.js): gridOptions.data string value now works again.
Browse files Browse the repository at this point in the history
Added back if statement in the dataWatchFunction and added an $eval to ensure controllerAs systax is
supported.

fix #6377, fix #6155
  • Loading branch information
Portugal, Marcelo authored and mportuga committed Apr 2, 2018
1 parent 2f001f1 commit c62b986
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
18 changes: 10 additions & 8 deletions misc/tutorial/106_binding.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ For better performance with the following example, you can choose to load the ui
app.controller('MainCtrl', function MainCtrl() {
var vm = this;

vm.myData = [
{
'first-name': 'Cox',
friends: ['friend0'],
address: {street: '301 Dove Ave', city: 'Laurel', zip: '39565'},
getZip: function() {return this.address.zip;}
}
];

vm.gridOptions = {
enableSorting: true,
columnDefs: [
Expand All @@ -36,14 +45,7 @@ For better performance with the following example, you can choose to load the ui
{ name:'city', field: 'address.city'},
{ name:'getZip', field: 'getZip()', enableCellEdit: false}
],
data: [
{
'first-name': 'Cox',
friends: ['friend0'],
address: {street: '301 Dove Ave', city: 'Laurel', zip: '39565'},
getZip: function() {return this.address.zip;}
}
]
data: '$ctrl.myData'
};
});
</file>
Expand Down
10 changes: 6 additions & 4 deletions src/js/core/directives/ui-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@
// gridUtil.logDebug('dataWatch fired');
var promises = [];

if (angular.isString($scope.uiGrid.data)) {
newData = self.grid.appScope[$scope.uiGrid.data];
} else {
newData = $scope.uiGrid.data;
if ( self.grid.options.fastWatch ) {
if (angular.isString($scope.uiGrid.data)) {
newData = self.grid.appScope.$eval($scope.uiGrid.data);
} else {
newData = $scope.uiGrid.data;
}
}

mostRecentData = newData;
Expand Down

0 comments on commit c62b986

Please sign in to comment.