我有一个自动关闭的 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;
}
这里应该是什么问题?它以前工作得很好。