Angular 2 ng-bootstrap ngbAlert错误

时间:2016-10-11 08:21:16

标签: angular typescript ng-bootstrap

我有一个自我关闭的ng-bootstrap警报实现为

<span *ngFor="let alert of alerts">
    <template ngbAlert [dismissOnTimeout]="5000" [type]="alert.type"><span [innerHTML]="alert.message"></span></template>
</span>

它工作得很好。但是,当我启动一个新项目并按原样复制该组件时,它现在提供

    Promise rejection: Template parse errors:
Can't bind to 'dismissOnTimeout' since it isn't a known property of 'template'.

如果需要,这是我的ts文件

import { Input, Component } from '@angular/core';

@Component({
  selector: 'ngbd-alert-closeable',
  templateUrl: './client/app/html/components/alert-closeable.html',
  styleUrls: ['./client/app/css/components/alert-closeable.css']
})
export class NgbdAlertCloseable {

  @Input()
  public alerts: Array<IAlert> = [];

  public addSuccess(msg: string, alert: IAlert) {
    this.alerts.push({
      type: 'success',
      message: msg
    });
  }

  public addInfo(msg: string, alert: IAlert) {
    this.alerts.push({
      type: 'info',
      message: msg
    });
  }

  public addWarning(msg: string, alert: IAlert) {
    this.alerts.push({
      type: 'warning',
      message: msg
    });
  }

  public addDanger(msg: string, alert: IAlert) {
    this.alerts.push({
      type: 'danger',
      message: msg
    });
  }

}

interface IAlert {
  type: string;
  message: string;
}

这里应该是什么问题?它以前工作得很好。

0 个答案:

没有答案