angularjs ng-click无效的可能原因
2017-05-11 19:04
309 查看
在uigrid里面使用celltemplate嵌入的按钮,使用ng-click点击不能打开新页面,需要增加grid.appScope.具体的函数名切换scope才可以
错误例子:
cellTemplate: '<div ng-switch=row.entity.goodsStatus>' +
'<div ng-switch-when=0><p style="margin-top: 1px"> <button ng-click="onShelf(\'\',\'onShelf.html\',\'on\',row.entity)" class="btn btn-danger btn-xs btn-sm" ><i class="fa fa-close"></i>上架</button></p></div>'
+'</div>',
正确例子:
cellTemplate: '<div ng-switch=row.entity.goodsStatus>' +
'<div ng-switch-when=0><p style="margin-top: 1px"> <button ng-click="grid.appScope.onShelf(\'\',\'onShelf.html\',\'on\',row.entity)" class="btn btn-danger btn-xs btn-sm" ><i class="fa fa-close"></i>上架</button></p></div>'
+'</div>',
错误例子:
cellTemplate: '<div ng-switch=row.entity.goodsStatus>' +
'<div ng-switch-when=0><p style="margin-top: 1px"> <button ng-click="onShelf(\'\',\'onShelf.html\',\'on\',row.entity)" class="btn btn-danger btn-xs btn-sm" ><i class="fa fa-close"></i>上架</button></p></div>'
+'</div>',
正确例子:
cellTemplate: '<div ng-switch=row.entity.goodsStatus>' +
'<div ng-switch-when=0><p style="margin-top: 1px"> <button ng-click="grid.appScope.onShelf(\'\',\'onShelf.html\',\'on\',row.entity)" class="btn btn-danger btn-xs btn-sm" ><i class="fa fa-close"></i>上架</button></p></div>'
+'</div>',
相关文章推荐
- angularjs ng-click 传参数
- angularjs directive ng-repeat里ng-click 不起作用解决办法
- angularjs ng-click
- angularjs ng-click 方法中的this指向的$scope
- angularjs ng-click传参控制ng-repeat元素显示与隐藏
- Angular 动态生成html中 ng-click无效
- How to call a service function in AngularJS ng-click
- AngularJS ngTouch 插件,替代原来的ng-click
- angularjs ng-click 阻止事件冒泡
- angularjs input ng-model 双向绑定无效的问题
- Angular 动态生成html中 ng-click无效
- AngularJS ng-disabled在a内无效
- AngularJS ng-model在ng-if里面无效
- angularjs ng-click获取当前元素
- Angular 动态生成html中 ng-click无效
- angularjs ng-style background-image的用法及坑
- 此页的状态信息无效,可能已损坏 的处理办法及原因分析
- angularjs ng-class 两种用法
- angular.min.js:118 Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?
- angularjs ng-repeat 获取当前在数组中的下标