扫码关注官方订阅号
{{goods.name}} 对td内容进行修改 现在我想获取点击td 弹出当前td的内容。 怎么实现。
业精于勤,荒于嬉;行成于思,毁于随。
<tr ng-repeat="goods in $data"> <td ng-click="show($event)" contenteditable="true" > {{goods.name}} </td> </tr> function show(e){ alert(e.target.innerText) } ng-model是双向数据绑定可以随时获取值,但ng-model只作用于input标签和一些文本标签上。所以根据你的需求,只能通过dom去获取文本上的内容,但不是实时的,这一些修改的值下次点击才会得到。
<tr ng-repeat="goods in $data track by $index"> <td ng-click=consoleSomeThing($index)> {{goods.name}} </td> </tr> //js部分 $scope.consoleSomeThing=function(index){ //具体看你的$data结构了,复杂点的就去遍历吧,反正重点是拿到对应的索引index console.log($data[index].goods.name) }
使用name = angular.element($event.target).text()
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
使用
name = angular.element($event.target).text()