0

I have my default gridOptions in a parent controller.

EG:

  $scope.gridOptions = {
        rowHeight:50,
        headerHeight:50,
        onRegisterApi = function(gridApi,$scope){...}
}

The child controllers that implement UI-Grids all inherit the parent $scope and that seems to work fine for props with primitive types.

But, in the onRegisterApi function, I need to be able to access local variables and methods that are not in the parent scope.

I'm pretty sure I need to use a JS Inheritance pattern, but I'm having a hard time making it work. I've checked out: http://blog.mgechev.com/2013/12/18/inheritance-services-controllers-in-angularjs/ and https://www.exratione.com/2013/10/two-approaches-to-angularjs-controller-inheritance/

jbd
  • 413
  • 5
  • 14

1 Answers1

0

This worked for me: What's the recommended way to extend AngularJS controllers?

I put all my UI-Grid defaults in a base controller, which I then extend in the the controller that implements the grid. Seems to work fine without any $scope issues.

Community
  • 1
  • 1
jbd
  • 413
  • 5
  • 14