AngularJs Type error : Cannot read property 'childNodes' of undefined

一、在AngularJs和JQuery插件共存咋项目中经常会遇到如下异常

[html]  view plain  copy
  1. Type error : Cannot read property 'childNodes' of undefined  


解决方案1:

[javascript]  view plain  copy
  1. $timeout(init, 0);  

引用$timeout服务,异步执行JQuery的初始化代码

解决方案2:

[javascript]  view plain  copy
  1. angular.element(document).ready(function () {  
  2.     //Angular breaks if this is done earlier than document ready.  
  3.     setupSliderPlugin();  
  4. });  
 在angularjs初始化视图之后执行JQuery 的绑定

二、在使用Bootstrap-table绑定工具栏是就会遇到如上问题

[html]  view plain  copy
  1. @*工具栏*@  
  2. <div id="toolBar">  
  3.     <div class="btn-group">  
  4.         <a class="btn green" ng-click="addBtnClick()"><i class="fa fa-plus">新建</i></a>  
  5.         <a class="btn red"><i class="fa fa-trash">删除</i></a>  
  6.     </div>  
  7. </div>  
[html]  view plain  copy
  1. <table id="datatable" class="table table-striped table-hover table-bordered"  
  2.         data-search="true"    
  3.         data-show-refresh="true"    
  4.         data-show-toggle="true"    
  5.         data-show-columns="true"    
  6.         data-toolbar="#toolBar">  
  7. </table>  
控制器加载成功,绑定列表
[javascript]  view plain  copy
  1. //绑定列表  
  2. var table = null;  
  3. $timeout(function () {  
  4.     table = $('#datatable').bootstrapTable({  
  5.         columns: [  
  6.             { field: 'checkbox', title: '主键', checkbox: true },  
  7.             { field: 'Name', title: '角色名称' },  
  8.             { field: 'SortValue', title: '排序列' },  
  9.             {  
  10.                 field: 'IsSys', title: '角色分类', formatter(value, row, index) {  
  11.                     if (value)  
  12.                         return '内置角色';  
  13.                     return '自定义角色';  
  14.                 }  
  15.             },  
  16.             {  
  17.                 filed: 'RoleID', title: '操作', formatter(value, row, index) {  
  18.                     var btn = '';  
  19.                     btn += '<span class="btn btn-xs blue" title="编辑"><i class="fa fa-edit"></i></span>';  
  20.                     btn += '<span class="btn btn-xs purple" title="权限"><i class="fa fa-gears"></i></span>';  
  21.                     return btn;  
  22.                 }  
  23.             }  
  24.         ],  
  25.         url: '/admin/menu/getlist_role',  
  26.         pagination: true,  
  27.         sidePagination: 'server',  
  28.         queryParams: function (params) {  
  29.             return params;  
  30.         }  
  31.     });  
  32. }, 0); 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值