Commit 2ce2db7f44ca1fef22c01c91fd3a807741c98f66

Authored by Arsisakarn Srilatanart
1 parent 522b64d0
Exists in master

แยก layout สำหรับ ui (มี header/footer) กับสำหรับ print (ไม่มี header/footer)

@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 "@angular/platform-browser": "^4.0.0", 20 "@angular/platform-browser": "^4.0.0",
21 "@angular/platform-browser-dynamic": "^4.0.0", 21 "@angular/platform-browser-dynamic": "^4.0.0",
22 "@angular/router": "^4.0.0", 22 "@angular/router": "^4.0.0",
  23 + "angular2-logger": "^0.6.0",
23 "core-js": "^2.4.1", 24 "core-js": "^2.4.1",
24 "rxjs": "^5.1.0", 25 "rxjs": "^5.1.0",
25 "zone.js": "^0.8.4" 26 "zone.js": "^0.8.4"
src/app/app-routing.module.ts
@@ -5,25 +5,41 @@ import { WizardBaseComponent } from './wizard-base/wizard-base.component'; @@ -5,25 +5,41 @@ import { WizardBaseComponent } from './wizard-base/wizard-base.component';
5 import { ModalOneComponent } from './wizard-base/modal-one/modal-one.component'; 5 import { ModalOneComponent } from './wizard-base/modal-one/modal-one.component';
6 import { ModalTwoComponent } from './wizard-base/modal-two/modal-two.component'; 6 import { ModalTwoComponent } from './wizard-base/modal-two/modal-two.component';
7 import { DummyComponent } from './dummy/dummy.component'; 7 import { DummyComponent } from './dummy/dummy.component';
  8 +import { LayoutUiComponent } from './layouts/ui.component';
  9 +import { LayoutPrintComponent } from './layouts/print.component';
  10 +import { InvoiceComponent } from './invoice/invoice.component';
8 11
9 const routes: Routes = [ 12 const routes: Routes = [
  13 + { path: '', redirectTo: '/wizard', pathMatch: 'full' },
10 { 14 {
11 - path: 'wizard',  
12 - component: WizardBaseComponent, 15 + path: '',
  16 + component: LayoutUiComponent,
13 children: [ 17 children: [
14 - { path: '1', component: ModalOneComponent },  
15 - { path: '2', component: ModalTwoComponent }, 18 + {
  19 + path: 'wizard',
  20 + component: WizardBaseComponent,
  21 + children: [
  22 + { path: '1', component: ModalOneComponent },
  23 + { path: '2', component: ModalTwoComponent },
  24 + ]
  25 + },
  26 + {
  27 + path: 'dummy',
  28 + component: DummyComponent
  29 + },
16 ] 30 ]
17 }, 31 },
18 { 32 {
19 - path: 'dummy',  
20 - component: DummyComponent  
21 - },  
22 - { path: '', redirectTo: '/wizard', pathMatch: 'full' }, 33 + path: 'print',
  34 + component: LayoutPrintComponent,
  35 + children: [
  36 + { path: 'invoice', component: InvoiceComponent },
  37 + ],
  38 + }
23 ]; 39 ];
24 40
25 @NgModule({ 41 @NgModule({
26 - imports: [ RouterModule.forRoot(routes) ], 42 + imports: [ RouterModule.forRoot(routes, { useHash: true }) ],
27 exports: [ RouterModule ] 43 exports: [ RouterModule ]
28 }) 44 })
29 export class AppRoutingModule { 45 export class AppRoutingModule {
src/app/app.module.ts
@@ -11,6 +11,9 @@ import { ModalOneComponent } from './wizard-base/modal-one/modal-one.component'; @@ -11,6 +11,9 @@ import { ModalOneComponent } from './wizard-base/modal-one/modal-one.component';
11 import { ModalTwoComponent } from './wizard-base/modal-two/modal-two.component'; 11 import { ModalTwoComponent } from './wizard-base/modal-two/modal-two.component';
12 import { SharedServiceService } from './services/shared-service.service'; 12 import { SharedServiceService } from './services/shared-service.service';
13 import { DummyComponent } from './dummy/dummy.component'; 13 import { DummyComponent } from './dummy/dummy.component';
  14 +import { InvoiceComponent } from './invoice/invoice.component';
  15 +import { LayoutUiComponent } from './layouts/ui.component';
  16 +import { LayoutPrintComponent } from './layouts/print.component';
14 17
15 @NgModule({ 18 @NgModule({
16 declarations: [ 19 declarations: [
@@ -18,7 +21,10 @@ import { DummyComponent } from './dummy/dummy.component'; @@ -18,7 +21,10 @@ import { DummyComponent } from './dummy/dummy.component';
18 WizardBaseComponent, 21 WizardBaseComponent,
19 ModalOneComponent, 22 ModalOneComponent,
20 ModalTwoComponent, 23 ModalTwoComponent,
21 - DummyComponent 24 + DummyComponent,
  25 + InvoiceComponent,
  26 + LayoutUiComponent,
  27 + LayoutPrintComponent,
22 ], 28 ],
23 imports: [ 29 imports: [
24 BrowserModule, 30 BrowserModule,
src/app/invoice/invoice.component.css 0 → 100644
src/app/invoice/invoice.component.html 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +<p>
  2 + invoice works!
  3 +</p>
src/app/invoice/invoice.component.spec.ts 0 → 100644
@@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
  1 +import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  2 +
  3 +import { InvoiceComponent } from './invoice.component';
  4 +
  5 +describe('InvoiceComponent', () => {
  6 + let component: InvoiceComponent;
  7 + let fixture: ComponentFixture<InvoiceComponent>;
  8 +
  9 + beforeEach(async(() => {
  10 + TestBed.configureTestingModule({
  11 + declarations: [ InvoiceComponent ]
  12 + })
  13 + .compileComponents();
  14 + }));
  15 +
  16 + beforeEach(() => {
  17 + fixture = TestBed.createComponent(InvoiceComponent);
  18 + component = fixture.componentInstance;
  19 + fixture.detectChanges();
  20 + });
  21 +
  22 + it('should create', () => {
  23 + expect(component).toBeTruthy();
  24 + });
  25 +});
src/app/invoice/invoice.component.ts 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +import { Component, OnInit } from '@angular/core';
  2 +
  3 +@Component({
  4 + selector: 'app-invoice',
  5 + templateUrl: './invoice.component.html',
  6 + styleUrls: ['./invoice.component.css']
  7 +})
  8 +export class InvoiceComponent implements OnInit {
  9 +
  10 + constructor() { }
  11 +
  12 + ngOnInit() {
  13 + }
  14 +
  15 +}
src/app/layouts/print.component.html 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<router-outlet></router-outlet>
src/app/layouts/print.component.ts 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +import { Component } from '@angular/core';
  2 +
  3 +@Component({
  4 + selector: 'layout-print',
  5 + templateUrl: './print.component.html',
  6 +})
  7 +export class LayoutPrintComponent {
  8 +
  9 +}
src/app/layouts/ui.component.html 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +Header
  2 +<hr />
  3 +<router-outlet></router-outlet>
  4 +<hr />
  5 +Footer
src/app/layouts/ui.component.ts 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +import { Component } from '@angular/core';
  2 +
  3 +@Component({
  4 + selector: 'layout-ui',
  5 + templateUrl: './ui.component.html',
  6 +})
  7 +export class LayoutUiComponent {
  8 +
  9 +}