angularjs ng-click无效的可能原因

来源:互联网 发布:黄金储备数据 编辑:程序博客网 时间:2024/05/16 10:27
在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>',

0 0
原创粉丝点击