typescript NG-警报
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript NG-警报相关的知识,希望对你有一定的参考价值。
@Component({
selector:'ng-alerts',
template:`<div class="dock-header" [ngClass]="options.place +' dock-size-'+options.size">
<div single-alert *ngFor="let alert of alerts" [alert]="alert" (onClosed)="closed()">
</div>
</div>`,
styleUrls:['./ng-alerts.css'],
encapsulation:ViewEncapsulation.None
})
export class NgAlertsComponent implements OnInit{
options:any={};
alerts:any=[];
queue:any=[];
private _countsAlerts=0;
constructor(private alertsService:NgAlertsService){
}
ngOnInit(){
this.alertsService.eventAlerts.subscribe((alert)=>{
if(alert){
if(this._countsAlerts < this.options.limit){
this.alerts.unshift(alert);
this._countsAlerts++;
}else{
this.queue.push(alert);
}
}
});
this.alertsService.eventOptions.subscribe((options:AlertModel)=>{
if(options){
this.options=options;
}
})
}
closed(e,alert){
this._countsAlerts--;
if(this.queue.length){
this.alerts.unshift(this.queue.shift());
this._countsAlerts++;
}
}
}
以上是关于typescript NG-警报的主要内容,如果未能解决你的问题,请参考以下文章
typescript NG-警报
typescript NG-警报
typescript NG-警报
typescript NG-警报
html NG-警报
typescript 按选择显示警报