Create new ui-grid by using a factory: what is the scope - parameter to use the ui-grid-event-handler?

一个人想着一个人 提交于 2019-12-11 13:39:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!