【发布时间】:2020-02-16 18:44:02
【问题描述】:
我在学习angularjs,想写一个自定义的“可编辑”指令,可以让普通的html元素“可编辑”:
当用户点击它时,它会显示一个文本输入或文本区域让用户编辑内容,此外还有一个“更新”和“取消”按钮。用户可以点击“更新”按钮或按“Ctrl+enter”提交修改的内容,或点击“取消”或按“escape”取消修改。
“可编辑”签名看起来像:
<div editable
e-trigger="click|dblclick" /* use click or dblclick to trigger the action */
e-update-url="http://xxx/xxx" /* when submitting, the data will PUT to this url */
e-singleline="true|false" /* if ture, use text input, otherwise textarea */
ng-model="name"> /* the corresponding model name */
{{name}}
</div>
我在这里创建了一个现场演示:http://jsfiddle.net/Freewind/KRduz/,你可以更新它。
【问题讨论】:
标签: angularjs