<ul class="nav nav-tabs" id="myTab" role="tablist">
<li [className]="titleActive ? 'nav-item active' : 'nav-item'">
<a class="nav-link active wow fadeIn" id="home-tab" data-toggle="tab" href="#home-1" role="tab" aria-controls="home" aria-selected="true">HOT JOBS</a></li>
<li class="nav-item">
<a class="nav-link wow fadeIn" id="profile-tab" data-toggle="tab" href="#profile-1" role="tab" aria-controls="profile" aria-selected="false">ALL JOBS</a>
</li>
</ul>
Ts文件 titleActive:any ='true';
某些情况 this.titleActive ='false';
答案 0 :(得分:1)
使用ngClass,
<li [ngClass]="titleActive ? 'nav-item active' : 'nav-item'">
答案 1 :(得分:0)
尝试使用[ngClass]
<li [ngClass]="titleActive == 'true' ? 'nav-item active' : 'nav-item'">
<!-- content -->
</li>