AngularJS,与棱角分明的前pression NG-阶级和阶级区别? [英] AngularJS, difference between ng-class and class with angular expression?

查看:125
本文介绍了AngularJS,与棱角分明的前pression NG-阶级和阶级区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么以下两个code片段之间的差异,
结果code 1:

 < D​​IV CLASS = {{的getClass()}} />

code 2:

 < D​​IV纳克级=的getClass()/>


解决方案

通过您的类将字面上角加载之前的第一个例子{{的getClass()}}。而在第二个实施例的股利将不具有类直到角速度运行其第一摘要。

有可能是,当他们重新计算,但角将保留两个最新的一些细微的差别。我使用带有动画的第一个方法,NG-类有一些挂钩插入动画之前碰到的问题。

What is the difference between the following two code snippets,
Code 1:

<div class={{getClass()}}/>

Code 2:

<div ng-class=getClass()/>

解决方案

With the first example before angular loads your class will literally be "{{getClass()}}". While in the second example the div won't have a class until angular runs its first digest.

There might be some minor differences with when they are recalculated but Angular will keep both up to date. I've run into issues before using the first method with Animation as ng-class has some hooks into animation.

这篇关于AngularJS,与棱角分明的前pression NG-阶级和阶级区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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