AngularJS ng-value 和 ng-model 不能一起工作 [英] AngularJS ng-value and ng-model do not work together

查看:34
本文介绍了AngularJS ng-value 和 ng-model 不能一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 ngvalue 为 textfield 赋值,而 textarea 具有该值,但是当我提交时,它识别为 textarea 为空.

I was trying to give a value to textfield using ngvalue and textarea has that value but it when I submit it, it recognized as textarea is empty.

 <textarea  ng-value="main.record.basic_info.application_letter"
            class="form-control" 
            ng-model="main.record.apply_job.cover_letter" 
            name="name" rows="15" cols="80" style="resize: none">
 </textarea>

推荐答案

这些指令不能一起使用

它还可以用于实现给定表达式与输入元素(例如 input[text] 或 textarea)的单向绑定,当该元素不使用 ngModel 时."

"It can also be used to achieve one-way binding of a given expression to an input element such as an input[text] or a textarea, when that element does not use ngModel."

您应该在控制器中设置此值,而不是使用 ng-value.

You should set this value in your controller rather than use ng-value.

这篇关于AngularJS ng-value 和 ng-model 不能一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆