admin管理员组

文章数量:1355529

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.

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.

Share Improve this question asked Feb 4, 2013 at 16:00 OrganiccatOrganiccat 5,65118 gold badges60 silver badges106 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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

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

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

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

Try adding any of these functions in the html where you call the .js function

 <script>
    $(function() {

 $('#fieldName').attr("readonly","readonly");

 });
</script>

OR

     <script>
    $(function() {

 $('#fieldName').attr("readonly", true);

 });
</script>

Where #fieldName is the id of the input field.

本文标签: javascriptReplace input field with read only text in AngularJSStack Overflow