From 56768d5f81058731e1ed44708d2589b67873074a Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 16 May 2018 17:25:04 +0900 Subject: [PATCH] test --- src/app/app-routing.module.ts | 2 +- .../pages/error/error-page-routing.module.ts | 16 ++++++++++++++++ src/app/pages/error/error-page.component.html | 1 + src/app/pages/error/error-page.component.ts | 18 ++++++++++++++++++ src/app/pages/error/error-page.module.ts | 18 ++++++++++++++++++ src/app/pages/probe/probe-page.component.ts | 15 +++++++++++---- 6 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 src/app/pages/error/error-page-routing.module.ts create mode 100644 src/app/pages/error/error-page.component.html create mode 100644 src/app/pages/error/error-page.component.ts create mode 100644 src/app/pages/error/error-page.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 67ccee9..6b789a5 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -5,7 +5,7 @@ import { AuthGuard } from './commons/guard/auth.guard'; const routes: Routes = [ { path: '', loadChildren: './pages/pages.module#PagesModule', canActivate: [AuthGuard] }, { path: 'auth', loadChildren: './pages/auth/auth-page.module#AuthPageModule' }, - // { path: '**', component: NotFoundPageComponent }, + { path: '**', loadChildren: './pages/error/error-page.module#ErrorPageModule' }, // { path: 'errors', loadChildren: './pages/errors/errors-page.module#ErrorsPageModule' }, ]; diff --git a/src/app/pages/error/error-page-routing.module.ts b/src/app/pages/error/error-page-routing.module.ts new file mode 100644 index 0000000..ce770d7 --- /dev/null +++ b/src/app/pages/error/error-page-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { ErrorPageComponent } from './error-page.component'; + +const routes: Routes = [ + { + path: '', + component: ErrorPageComponent, + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class ErrorPageRoutingModule { } diff --git a/src/app/pages/error/error-page.component.html b/src/app/pages/error/error-page.component.html new file mode 100644 index 0000000..a591d7d --- /dev/null +++ b/src/app/pages/error/error-page.component.html @@ -0,0 +1 @@ +Error Page \ No newline at end of file diff --git a/src/app/pages/error/error-page.component.ts b/src/app/pages/error/error-page.component.ts new file mode 100644 index 0000000..c443c6f --- /dev/null +++ b/src/app/pages/error/error-page.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit } from '@angular/core'; + + + +@Component({ + selector: 'of-pages-error', + templateUrl: './error-page.component.html', +}) + +export class ErrorPageComponent implements OnInit { + + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/pages/error/error-page.module.ts b/src/app/pages/error/error-page.module.ts new file mode 100644 index 0000000..17a91ee --- /dev/null +++ b/src/app/pages/error/error-page.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { ErrorPageComponent } from './error-page.component'; +import { ErrorPageRoutingModule } from './error-page-routing.module'; +import { PrimeNGModules } from 'packages/commons/prime-ng/prime-ng.module'; + +@NgModule({ + imports: [ + CommonModule, + ErrorPageRoutingModule, + PrimeNGModules, + ], + entryComponents: [ + ], + declarations: [ErrorPageComponent] +}) +export class ErrorPageModule { } diff --git a/src/app/pages/probe/probe-page.component.ts b/src/app/pages/probe/probe-page.component.ts index 5a8e5b8..766b373 100644 --- a/src/app/pages/probe/probe-page.component.ts +++ b/src/app/pages/probe/probe-page.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { Subscription } from 'rxjs/Subscription'; @@ -6,19 +6,26 @@ import { Subscription } from 'rxjs/Subscription'; selector: 'of-pages-probe', templateUrl: './probe-page.component.html', }) -export class ProbePageComponent { +export class ProbePageComponent implements OnInit, OnDestroy { private tabs = undefined; - private routerSubscription: Subscription; + private routerSubscription$: Subscription; constructor(private router: Router) { - router.events.subscribe((event) => { + } + + ngOnInit() { + this.routerSubscription$ = this.router.events.subscribe((event) => { if (event instanceof NavigationEnd) { this.generateTabMenu(event); } }); } + ngOnDestroy() { + this.routerSubscription$.unsubscribe(); + } + generateTabMenu(event: NavigationEnd) { const parsedUrl = event.url.split('probe/')[1].split('/')[0]; switch (parsedUrl) {