Angular 2. What is faster to render: [ngClass] or class=“{{}}”?
问题 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