Angular 具有ngFor属性的元素上的变量的附加类
这是显示列表的“我的离子”按钮:Angular 具有ngFor属性的元素上的变量的附加类,angular,ionic-framework,ionic2,Angular,Ionic Framework,Ionic2,这是显示列表的“我的离子”按钮: <button ion-item text-wrap *ngFor="let task of tasks" (click)="gotoTask(task)"> 它产生: <button class="item-block item item-ios" ion-item="" text-wrap=""> 当我尝试以这种方式添加类时 <button ion-item text-wrap *ngFor="let task of
<button ion-item text-wrap *ngFor="let task of tasks" (click)="gotoTask(task)">
它产生:
<button class="item-block item item-ios" ion-item="" text-wrap="">
当我尝试以这种方式添加类时
<button ion-item text-wrap *ngFor="let task of tasks" (click)="gotoTask(task)" class="{{task.status}}">
它会中断并最终成为:
<button class="completed" ion-item="" text-wrap="" ng-reflect-class-name="completed">
这看起来显然不对
向按钮添加类的正确方法是什么?更好的方法是使用
ngClass
指令
<button ion-item text-wrap *ngFor="let task of tasks"
(click)="gotoTask(task)"
[ngClass]="task.status">
ng reflect class name=“completed”
是Angular2为内部处理添加的信息。您觉得什么不合适?Iclass=“completed”
不是你想要的?哈,你得到了。谢谢你的回答。
[class.someStaticClass]="booleanExpression"