Bootstrap类.活性在Angular 8中不起作用



[class.active]在我的代码中不起作用,然后我使用Angular和Old版本的Bootstrap,但现在在Angular 8和Bootstrap上升级4.2.1是否工作代码在这里

<a *ngFor="let cat of categoryArray;let i=index;"
                routerLink="/" 
                [queryParams]="{category: cat.CategoryId}"
                class="list-group-item list-group-item-action" 
                [class.active]= "category === cat.CategoryId"   
                (click)="fileUploadComponent.Save()"
                >               
                  {{cat.Name}}
              </a>

问题是,以下行总是错误的,但实际上不应该。

[class.active]= "category === cat.CategoryId"

有什么问题?

尝试使用:

[attr.routerLinkActive]="category === cat.CategoryId ? 'active: null"
[ngClass]="{'active': category == cat.CategoryId}"

最新更新