简体   繁体   English

如何使用angularjs使表格列中的列可编辑?

[英]how to make column editable in table column with angularjs?

Is it possible to make a tablecolumn editable when using angularjs? 使用angularjs时可以使表格列可编辑吗? I have this table: 我有这张桌子:

<table>
    <thead>
    <tr class="header">
        <th>id</th>
        <th>files</th>
    </tr>
    </thead>
    <tbody ng-repeat="person in persons">
    <tr>
        <td>{{person.id}}</td>
        <td>{{person.fileNames)}}</td>
    </tr>
    </tbody>
</table>

So I have a $scope.fileNames which is an array containing filenames per person for example: 所以我有一个$ scope.fileNames这是一个包含每个人的文件名的数组,例如:

["Koala.jpg","Tulips.jpg","Tulips.jpg","Hydrangeas.jpg","Lighthouse.jpg","Chrysanthemum.jpg"]

I would like to make this 2nd column editable for the user so he can change/delete the files how can I accomplish this? 我想使用户可以编辑此第二列,以便他可以更改/删除文件,我该怎么做?

Use contentEditable 使用contentEditable

<table>
    <thead>
    <tr class="header">
        <th>id</th>
        <th>files</th>
    </tr>
    </thead>
    <tbody ng-repeat="person in persons">
    <tr>
        <td contentEditable>{{person.id}}</td>
        <td contentEditable>{{person.fileNames)}}</td>
    </tr>
    </tbody>
</table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM