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

查看:238
本文介绍了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>

推荐答案

您不能一起使用这些指令

You cannot use these directives together

"当该元素不使用ngModel时,也可以用于将给定表达式单向绑定到输入元素,例如input [text]或textarea ."

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

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

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

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