您的位置:首页 > Web前端 > AngularJS

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>',
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  angularjs ng-click