在AngularJS只读文本更换输入字段字段、文本、AngularJS

2023-09-13 02:37:07 作者:我发誓我再也不发誓了

我有一些jQuery当前设置为从视图中删除输入字段和写入输入域作为一个跨度内的纯文本的价值,但我想知道AngularJS将如何处理这个问题。该事件发生后,提交表单,这部分是通过AJAX已经完成了为好。这不只是一个输入,它的所有的人的形式,所以你可以看到你刚刚提交什么结果。

I have some jQuery currently set up to remove the input field from view and write the value of the input field as plain text inside a span, however I'm wondering how AngularJS would handle this. The event happens upon submitting a form, that part is already done through ajax as well. It's not just one input, it's all of them on the form so you can see the results of what you just submitted.

推荐答案

使用 NG-显示并/或在每个输入字段NG隐藏及其相关文本等价的。

Use ng-show and/or ng-hide on each input field and its associated text equivalent.

当您提交表单,切换一些$ scope属性:

When you submit the form, toggle some $scope property:

<input type="text" ... ng-model='text1' ng-show="editMode">
<span ng-hide="editMode">{{text1}}</span>

在你的控制器,初始化编辑模式为true。在你提交功能,设置为false。

In your controller, initialize editMode to true. In your submit function, set it to false.

 
精彩推荐
图片推荐