为什么不在angular4指令中应用标签成功和标签危险类?

时间:2017-11-22 11:24:34

标签: angular directive angular2-directives

我有一个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>

enter image description here enter image description here

0 个答案:

没有答案