简体   繁体   English

是否可以通过在Angular中使用jQuert attr元素设置ng-show?

[英]Is it possibile to set ng-show by using jQuert attr element in Angular?

I am trying to change the ng-show attribute of an element. 我正在尝试更改元素的ng-show属性。 But it seems that Angular ignore it. 但是,似乎Angular忽略了它。 Why? 为什么?

element.attr('ng-show',false)

I tried to do scope.$apply, buy still angular ignore this attribute. 我试图做scope。$ apply,仍然按角度购买忽略此属性。

Is it possible to change ng-show attribute after the run-time? 运行后是否可以更改ng-show属性?

ng-show should be assigned the value from the scope that resolves to a boolean. 应该为ng-show分配来自解析为布尔值的范围的值。 Changing that boolean scope variable to true or false should hide or show the element. 将该布尔值范围变量更改为true或false会隐藏或显示该元素。

Well, as it is explained here , after the Compilation phase for AngularJS any other directive that you insert in the HTML will be unreachable. 好了,正如这里所解释的那样 ,在AngularJS的编译阶段之后,您在HTML中插入的任何其他指令将无法访问。 That is because, Angular transverse the whole DOM only once in order to improve performance. 这是因为,Angular只对整个DOM进行一次横切以提高性能。

btw, why are you doing that? 顺便说一句,你为什么这样做? Instead I will prefer an attribute from a controller to listen directly on that particular element of your html. 取而代之的是,我希望控制器具有一个属性来直接侦听html的特定元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM