从包含ng网格对象的状态转换不起作用
Transitioning from a state containing an ng-grid object is not working
在我的AngularJS应用程序中,我使用ui路由器进行导航,并使用ng网格显示数据。在我从一个包含网格的状态转换到任何其他状态之前,一切都很好。这是相应的模板:
<div ng-controller="MainUserController" class="container-fluid">
<div class="row">
<div class="col-xs-3">
<div class="gridStyle" ng-grid="gridOptions"></div>
</div>
</div>
</div>
当从这个状态转换到任何其他状态时,我记录以下错误流:
TypeError: Cannot read property 'off' of null
at HTMLDivElement.<anonymous> (http://127.0.0.1:9000/bower_components/ng-grid/build/ng-grid.debug.js:1008:31)
at HTMLDivElement.jQuery.event.dispatch (http://127.0.0.1:9000/bower_components/jquery/dist/jquery.js:4624:9)
at HTMLDivElement.elemData.handle (http://127.0.0.1:9000/bower_components/jquery/dist/jquery.js:4292:46)
at Object.jQuery.event.trigger (http://127.0.0.1:9000/bower_components/jquery/dist/jquery.js:4533:12)
at jQuery.fn.extend.triggerHandler (http://127.0.0.1:9000/bower_components/jquery/dist/jquery.js:5241:24)
at removePatch [as remove] (http://127.0.0.1:9000/bower_components/angular/angular.js:2213:21)
at Object.leave (http://127.0.0.1:9000/bower_components/angular/angular.js:4079:17)
at Object.leave (http://127.0.0.1:9000/bower_components/angular-ui-router/release/angular-ui-router.js:2668:49)
at cleanupLastView (http://127.0.0.1:9000/bower_components/angular-ui-router/release/angular-ui-router.js:2717:22)
at http://127.0.0.1:9000/bower_components/angular-ui-router/release/angular-ui-router.js:2739:13
删除ng-grid="gridOptions"解决了这个问题,因此我认为我的冲突发生在ui路由器和ng-grid之间。
有什么见解吗?
编辑:这就是我声明gridOptions的方式。
$scope.gridOptions = {
data: 'data',
plugins: [new ngGridFlexibleHeightPlugin()],
showSelectionCheckbox: true,
columnDefs: [{ field: 'username', displayName: 'Name', width: "**" },
{ field: 'email', displayName: 'Email', width: "**"}]
};
关于ng网格和ui路由器的冲突,这个错误有一个悬而未决的问题,Herve Prot似乎找到了解决方案,我还没有测试它。
build/n-grid.js:中的第952行
grid.$topPanel.on('$destroy', function() {
if(grid.$topPanel == null) // FIX ui-router
return;
grid.$topPanel.off('mousedown');
if (grid.config.enableColumnReordering) {
grid.$topPanel.off('drop');
}
grid.$topPanel = null;
});
我还发现我需要更改以下内容(参见Alex Choroshin的帖子)
grid.$groupPanel.on('$destroy', function () {
if (grid.$groupPanel == null) // FIX ui-router
return;
grid.$groupPanel.off('mousedown');
grid.$groupPanel = null;
});
它只比建议的修复程序高出几行。
我解决了在ui路由器依赖项之前更改index.html依赖项中jQuery依赖项的顺序的问题。
相关文章:
- 混合 ui-sref 和 $state.go 在 Angular ui-router 中进行状态转换
- 无法在现有状态转换期间更新-未使用任何非法的setState()
- CSS转换立即进入最终状态
- 如何处理 React / Flux 组件中的状态转换
- Angular JS具有在状态转换期间可见的来自两个不同状态的页面(用于动画目的)
- 如何在AngularJS$rootScope事件侦听器中应用状态转换
- UI路由器-状态转换延迟(非常慢)
- 角度 UI 状态转换问题
- 从一种特定状态转换到另一种特定状态时执行操作
- 角度 UI 路由器 - 在没有参数的情况下从一个状态转换到同一状态失败
- index.js:1335警告:setState(..):无法在现有状态转换期间更新(例如在' render '或其他组
- Angular UI-Router——在resolve中返回被拒绝的承诺并不能停止状态转换
- ReactNativeJS:警告:setState(..):在现有状态转换期间无法更新(例如在“渲染”中)
- 添加“active"状态转换为Javascript
- 在AngularJS和Ionic中,每次状态转换都会发生两次导航
- React:警告:setState(..):在现有状态转换期间无法更新
- 从包含ng网格对象的状态转换不起作用
- Smooch:如何进行依赖于回发的状态转换
- 如何在状态转换之前暂停组件的延迟
- 在angular js中,如何将json对象作为状态转换的一部分发送到另一个控制器