ng-repeat中唯一的ng-bind-html

时间:2016-08-02 15:04:36

标签: angularjs angularjs-ng-repeat ng-bind-html

我的html是这样的,

<div ng-controller='gridDataController as gridDataCtrl'>
<table>
    <tbody>
        <tr ng-repeat="row in gridData" id="{{row.record_no}}">
            <td ng-bind-html="editInputA">{{row.a}}</td>
            <td ng-bind-html="editInputB">{{row.b}}</td>
            <td>
                <div>
                    <button ng-click="edit(row.record_no)" >edit</button>
                    <button ng-click="update(row.record_no)" >update</button>
                    <button ng-click="delete(row.record_no)" >delete</button>
                </div>
            </td>
        </tr>
    </tbody>
</table>

我希望编辑功能将输入框添加到单击编辑按钮的特定行,是否有任何角度方式,我也想要添加的输入框具有唯一ID,所以我可以触发它来更新编辑的文本。我正在寻找最好的角度练习,因为我是新手。在此先感谢:)

1 个答案:

答案 0 :(得分:0)

最好的方法是隐藏输入并用ngShow(https://docs.angularjs.org/api/ng/directive/ngShow

显示它
<body ng-app="ngAnimate">
    <button ng-click="showInput= !showInput" >edit</button>
    <div>
        <div class="check-element animate-show" ng-show="showInput">
        <input class="glyphicon glyphicon-thumbs-up" id="newInput">
        </div>
    </div>
</body>

我从ngShow中获取了一些示例,您可以将其与ngClick:

一起使用

https://plnkr.co/edit/Cgo5bFgNxhJUVbTwjzu8?p=preview

另一种方法是使用
    var input = var element = document.createElement(&#34; input&#34;);

但使用ng-show似乎可以更好地满足您的需求

相关问题