问题
I create an ui-grid in my controller by using an Factory-method, which creates an new Table-Object(ui-grid). But I got problems with setting up the scope in the ui-grid-event-handlers.
See my js fiddle example for better understanding.
In the jsfiddle you get now the error in the console:
Cannot read property '$on' of undefined
at Object.GridApi.registerEvent.feature.on.(anonymous function) [as navigate]
If I change the handler-paramter to null, everything works fine, but...
In my project, which uses ui-router and by using null as gridApi.cellNav.on.navigate-parameter, I get the error in console:
Cannot read property '$on' of undefined
at Object.GridApi.registerEvent.feature.on.(anonymous function) [as navigate]
Same error like above, but the parameter is self.scope!? But in my project, using scope as Parameter, which get passed into the Table-Object, which is an reference to my $scope in my controller, which I don't use cause of ui-router an controllerAs-syntax, everything works fine. But in my opinion, reference this is not correct!?
So my question is: Is anybody able to explain me, what should be the first parameter for the gridApi.cellNav.on.navigate-handler!? Null, scope, $scope, reference to scope-of controller...
If something is not clear, please give me a message and I try to give more infos.
Thanks a lot
P.S. Sorry for my bad english
来源:https://stackoverflow.com/questions/32607453/create-new-ui-grid-by-using-a-factory-what-is-the-scope-parameter-to-use-the