问题
What will render faster?
<div class="ololo" [ngClass]="{'my-class': myVar}">one</div>
or
<div class="ololo {{myVar ? 'my-class': ''}}">another</div>
or some another way?
回答1:
I did some research and can surely say that this approach
<div class="ololo" [ngClass]="{'my-class': myVar}">one</div>
works about 3 times slower than
<div class="ololo {{myVar ? 'my-class': ''}}">another</div>
please see a demo
https://stackblitz.com/edit/angular-fvtzck
来源:https://stackoverflow.com/questions/46605252/angular-2-what-is-faster-to-render-ngclass-or-class