ng-model 绑定不适用于 div [英] ng-model binding not working on div
问题描述
AngularJS 的两个绑定对 div 不起作用.我希望我的 div 是可编辑的,但它没有发生.任何人都可以请建议可能有什么问题吗?相同的绑定在文本框上工作正常.这是我的代码:
The two binding of AngularJS is not working on div. I want my div to be editable but it's not happening. Could anybody please suggest what could be wrong? The same binding works fine on textbox. This is my code:
<input type="text" ng-model="userProfile.firstName"/>
<div class="profile-name" contenteditable="true" ng-model="userProfile.firstName"></div>
推荐答案
请试试这个,它可能会有所帮助https://github.com/angular/angular.js/issues/528
Please try this, it might help https://github.com/angular/angular.js/issues/528
这是一个已有 3 年历史的未解决问题,很多人都希望修复.它被标记为 post-1.2-milestone
和 feature
而不是 bug.鉴于 Angular.js 于 2014 年 2 月发布了 1.2.13 版,目前看来团队中没有人关心这个问题.因此,您最好滚动自己的代码或坚持使用 input
/textarea
控件.
This is a 3 year old open issue that tons of people would like fixed. It's marked as a post-1.2-milestone
and a feature
rather than a bug. Seeing as Angular.js is on release 1.2.13 as of Feb 2014, it looks like no one on the team cares about this issue at the moment. As a result you'll be better off rolling your own code or sticking with a input
/textarea
control.
这篇关于ng-model 绑定不适用于 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!