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 badges2 Answers
Reset to default 9Use 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
版权声明:本文标题:javascript - Replace input field with read only text in AngularJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744050730a2582374.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论