fengxiang
2018-07-11 12b04f145bae740e1971036b1e2dfc1bc224d17b
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
import { Component, ViewChild, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { PageHeaderComponent } from '@delon/abc';
 
@Component({
  // tslint:disable-next-line:component-selector
  selector: 'pro-list-layout',
  templateUrl: './list.component.html',
})
export class ProListLayoutComponent implements OnInit {
  tabs: any[] = [
    {
      key: 'articles',
      tab: '文章',
    },
    {
      key: 'applications',
      tab: '应用',
    },
    {
      key: 'projects',
      tab: '项目',
    },
  ];
 
  @ViewChild('ph') ph: PageHeaderComponent;
 
  pos = 0;
 
  constructor(private router: Router) {}
 
  ngOnInit(): void {
    const key = this.router.url.substr(this.router.url.lastIndexOf('/') + 1);
    const idx = this.tabs.findIndex(w => w.key === key);
    if (idx !== -1) this.pos = idx;
  }
 
  to(item: any) {
    this.router
      .navigateByUrl(`/pro/list/${item.key}`)
      .then(() => this.ph.refresh());
  }
}