我有一个status指令,它根据@Input应用特定的bootstrap标签类,当我应用label-success或label-danger时它不起作用,当我应用label-info或label-warning时它起作用。< / p>
@Input() status: string;
@HostBinding('class.label-danger') private default = true; //not working
@HostBinding('class.label-success') private default = true; //not working
@HostBinding('class.label-warning') private default = true; //working
@HostBinding('class.label-info') private default = true; //working
在ngOnInit方法中,我将值更改为true或false,具体取决于状态文本。
<span class="label" appStatus [status]="status.slug">
{{ status.name }}
</span>