AngularJS Model未更新

时间:2014-11-26 07:46:50

标签: angularjs angularjs-ng-repeat

我在ng-repeat中得到了一个模型:

<tr ng-repeat="expert in experts">
                <td>{{expert.expertName}}</td>
                <td ng-mouseleave="editMode = false">
                    <span ng-hide="editMode" ng-click="editMode = !editMode">{{expert.mail}}</span>
                    <input class="width100" type="text" ng-show="editMode" value="{{expert.mail}}" />
                </td>
                <td><input class="width100" type="checkbox" ng-model="expert.locked" ng-click="showSaveButton = ! showSaveButton"/></td>
                <td class="width100">
                    <input type="button" class="btn btn-primary btn-success" ng-show="showSaveButton" value="SAVE" ng-click="confirmSave(expert)" />
                    <input type="button" class="btn-warning btn-primary btn" value="GENERATE" ng-click="" />
                </td>
            </tr>

问题就在这里:

<td ng-mouseleave="editMode = false">
                    <span ng-hide="editMode" ng-click="editMode = !editMode" ng-animate>{{expert.mail}}</span>
                    <input class="width100" type="text" ng-show="editMode" value="{{expert.mail}}" />
                </td>

当我进入编辑模式时,我可以编辑输入字段。当我离开时,跨度不会更新。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您可以使用ng-model而不是value = {{expert.email}}

   <input class="width100" type="text" ng-show="editMode" ng-model="expert.mail" />