如何使角度形式只读,并使用编辑按钮使其可编辑?

时间:2021-09-14 18:52:05

Is there a way to make the entire Angular form read only and then editable when clicking edit?

有没有办法让整个Angular表单只读,然后在单击编辑时可编辑?

2 个解决方案

#1


22  

You can individually disable all the form elements as suggested in the current answer/comments, or you can wrap all of your form elements in a <fieldset> (more info) tag and then enable/disable everything in one step:

您可以按照当前答案/注释中的建议单独禁用所有表单元素,也可以将所有表单元素包装在

(more info)标记中,然后在一个步骤中启用/禁用所有内容:

<form>
  <fieldset ng-disabled="myBooleanValue">
    <input type="text">
  </fieldset>
</form>

#2


3  

You can add ng-disabled="someBoolean" to your form elements, and set someBoolean to true when you click a button.

您可以将ng-disabled =“someBoolean”添加到表单元素,并在单击按钮时将someBoolean设置为true。

https://docs.angularjs.org/api/ng/directive/ngDisabled

https://docs.angularjs.org/api/ng/directive/ngDisabled

#1


22  

You can individually disable all the form elements as suggested in the current answer/comments, or you can wrap all of your form elements in a <fieldset> (more info) tag and then enable/disable everything in one step:

您可以按照当前答案/注释中的建议单独禁用所有表单元素,也可以将所有表单元素包装在

(more info)标记中,然后在一个步骤中启用/禁用所有内容:

<form>
  <fieldset ng-disabled="myBooleanValue">
    <input type="text">
  </fieldset>
</form>

#2


3  

You can add ng-disabled="someBoolean" to your form elements, and set someBoolean to true when you click a button.

您可以将ng-disabled =“someBoolean”添加到表单元素,并在单击按钮时将someBoolean设置为true。

https://docs.angularjs.org/api/ng/directive/ngDisabled

https://docs.angularjs.org/api/ng/directive/ngDisabled