sidebar.component.ts
1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {Component, Inject, Input} from "ng-forward";
import {SidebarNotificationService} from "./sidebar.notification.service";
import {SessionService} from '../../login/session.service';
@Component({
selector: 'sidebar',
templateUrl: 'app/layout/sidebar/sidebar.html'
})
@Inject(SidebarNotificationService, SessionService)
export class SidebarComponent {
@Input()
private visible: boolean = false;
@Input()
public user: { name: string } = {
name: ''
};
constructor(private notificationService: SidebarNotificationService, private session: SessionService) { }
ngOnInit() {
let userData: any = this.session.currentUser();
if (userData) {
this.user = userData.person;
}
this.notificationService.setVisibility(this.visible);
this.notificationService.subscribe((visible: boolean) => {
this.visible = visible;
});
}
isVisible(): boolean {
return <boolean>this.visible;
}
}