小编Pha*_*ani的帖子

ng-list中的contenteditable项目的双向绑定

我希望使用contenteditable属性更新电话列表中的电话名称.我尝试过使用ng-change但是没有被解雇.有什么方法可以做到这一点吗?

我有一份清单 Store.Phones

<ul class="store">
  <li ng-repeat="Phone in Store.Phones">
     <strong contenteditable> {{Phone.Name}}</strong>
  </li>
<ul>
Run Code Online (Sandbox Code Playgroud)

所以现在当我编辑电话名称时,我需要在列表中更新它.

我尝试了类似这样的东西,模型指向元素.这不起作用.

<strong ng-model='Store.Phones[$index].Name'> {{Phone.Name}}</strong>
Run Code Online (Sandbox Code Playgroud)

<strong ng-model='PhoneName' ng-change='PhoneNameChanged()'> {{Phone.Name}}</strong>
Run Code Online (Sandbox Code Playgroud)

但在这种情况下,该方法不会被解雇.

contenteditable angularjs angularjs-ng-repeat

12
推荐指数
1
解决办法
2万
查看次数