[英]Two way binding doesn't work if binding is set by jquery
I have this dom element with a {{name}}
binding 我有一个带有
{{name}}
绑定的dom元素
<div b="{{name}}"></div>
I want to access this div and update it's b
attribute via jquery like so: 我想访问这个div并通过jquery更新它的
b
属性,如下所示:
$('div').attr('b', 10)
, and I expect the two way binding to update the property on the according component. $('div').attr('b', 10)
,我希望两种方式的绑定可以更新相应组件上的属性。 But it doesn't work why? 但这为什么不起作用?
The reason you do binding is so that you can set the value from code and the change is reflected in template/html. 进行绑定的原因是可以从代码中设置值,并且更改会反映在template / html中。 You cannot make a change in html/dom using jquery and expect the change to be shown in code/controller!
您无法使用jquery在html / dom中进行更改,并且期望更改显示在代码/控制器中!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.