2017-04-15 49 views
0

我想应用一个类,如果一个值匹配任何一个数组的元素。我的方法如下 -使用数组作为表达式应用ngClass

sectionHeaders:Array<string>=["Appearance", "Personality and Interests", "Relationships", "In The Anime", "Anime", "Name", "Character Songs", "Trivia"]; 

<ion-item *ngFor="let info of characterInfo.sections"> 
    <h2 class="heading" [ngClass]='{"redBackground" : info?.title == sectionHeaders}'></h2> 
</ion-item> 

回答

相关问题