probe detail router

This commit is contained in:
insanity 2018-01-31 17:40:53 +09:00
parent 516a0bffa6
commit c89be32cf3
4 changed files with 24 additions and 13 deletions

View File

@ -1,3 +1,3 @@
<p> <p>
detail works! {{probeId}} detail
</p> </p>

View File

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
@Component({ @Component({
selector: 'of-detail', selector: 'of-detail',
@ -7,9 +8,12 @@ import { Component, OnInit } from '@angular/core';
}) })
export class DetailComponent implements OnInit { export class DetailComponent implements OnInit {
constructor() { } probeId = undefined;
constructor(private route: ActivatedRoute, private router: Router) { }
ngOnInit() { ngOnInit() {
this.probeId = this.route.snapshot.paramMap.get('id');
} }
} }

View File

@ -1,6 +1,7 @@
import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core'; import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
import { MatTableDataSource, MatSort } from '@angular/material'; import { MatTableDataSource, MatSort } from '@angular/material';
import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks'; import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks';
import { Router } from '@angular/router';
export interface Probe { export interface Probe {
id: string; id: string;
@ -50,12 +51,12 @@ export class ListComponent implements OnInit, AfterContentInit {
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
} }
constructor() { } constructor(private router: Router) { }
ngOnInit() { ngOnInit() {
} }
handleRowClick(obj: Probe) { handleRowClick(obj: Probe) {
alert(obj.id); this.router.navigate(['probe', obj.id]);
} }
} }

View File

@ -1,18 +1,24 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'of-pages-probe', selector: 'of-pages-probe',
templateUrl: './probe-page.component.html', templateUrl: './probe-page.component.html',
styleUrls: ['./probe-page.component.scss'] styleUrls: ['./probe-page.component.scss']
}) })
export class ProbePageComponent { export class ProbePageComponent implements OnInit {
tabs = [ tabs = undefined;
{ label: 'Info', path: '/probe' },
constructor(private router: Router) {
}
ngOnInit() {
this.tabs = [
{ label: 'Info', path: this.router.url },
{ label: 'Targets', path: '/target' }, { label: 'Targets', path: '/target' },
{ label: 'History', path: '/probe/history' }, { label: 'History', path: '/probe/history' },
]; ];
}
constructor() { }
} }