clr-angular-static-fix
Version:
1. Install Clarity Icons package through npm:
69 lines (57 loc) • 1.95 kB
text/typescript
/*
* Copyright (c) 2016-2018 VMware, Inc. All Rights Reserved.
* This software is released under MIT license.
* The full license information can be found in LICENSE in the root directory of this project.
*/
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Subscription } from 'rxjs';
import { ClrAlert } from './alert';
import { MultiAlertService } from './providers/multi-alert.service';
export class ClrAlertsPager implements OnInit, OnDestroy {
private multiAlertServiceChanges: Subscription;
/**
* Input/Output to support two way binding on current alert instance
*/
set currentAlert(alert: ClrAlert) {
if (alert) {
this.multiAlertService.currentAlert = alert;
}
}
get currentAlert() {
return this.multiAlertService.currentAlert;
}
currentAlertChange = new EventEmitter<ClrAlert>(false);
/**
* Input/Output to support two way binding on current alert index
*/
set currentAlertIndex(index: number) {
this.multiAlertService.current = index;
}
get currentAlertIndex() {
return this.multiAlertService.current;
}
currentAlertIndexChange = new EventEmitter<number>();
constructor(public multiAlertService: MultiAlertService) {}
ngOnInit() {
this.multiAlertServiceChanges = this.multiAlertService.changes.subscribe(index => {
this.currentAlertIndexChange.emit(index);
this.currentAlertChange.emit(this.multiAlertService.activeAlerts[index]);
});
}
pageUp() {
this.multiAlertService.next();
}
pageDown() {
this.multiAlertService.previous();
}
ngOnDestroy() {
this.multiAlertServiceChanges.unsubscribe();
}
}