-
Notifications
You must be signed in to change notification settings - Fork 175
/
navigation.component.ts
46 lines (39 loc) · 1.16 KB
/
navigation.component.ts
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
39
40
41
42
43
44
45
46
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { NavigationService } from './navigation.service';
@Component({
selector: 'stbui-navigation',
templateUrl: './navigation.component.html',
styleUrls: ['./navigation.component.scss']
})
export class NavigationComponent implements OnInit, OnDestroy {
navigationModel: any[];
navigationModelChangeSubscription: Subscription;
constructor(private service: NavigationService) {
console.log(1)
this.navigationModelChangeSubscription = this.service.onNavigationModelChange.subscribe(
navigation => {
this.navigationModel = navigation;
}
);
}
ngOnInit() {
this.addSubitemToNavigation()
}
ngOnDestroy() {
this.navigationModelChangeSubscription.unsubscribe();
}
updateExtendBadge() {
const extendNavItem = this.service.getNavigationItem('extend');
extendNavItem.badge.title = 6;
}
addSubitemToNavigation() {
const newNavItem = {
id: 'sub-item',
title: '动态添加菜单',
type: 'item',
url: '/apps/navigation'
};
this.service.addNavigationItem('extend', newNavItem);
}
}