BETTERZON-33: Added routing

This commit is contained in:
Patrick Müller 2020-12-02 09:02:24 +01:00
parent b5c9da6055
commit e91a0085f6
9 changed files with 73 additions and 55 deletions

View File

@ -0,0 +1,24 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from '@angular/router';
import {HelloWorldComponent} from './hello-world/hello-world.component';
import {AppComponent} from './app.component';
import {ProductListComponent} from './product-list/product-list.component';
const routes: Routes = [
{path: '', component: AppComponent},
{path: 'helloworld', component: HelloWorldComponent},
{path: 'pdp', component: ProductListComponent}
];
@NgModule({
declarations: [],
imports: [
RouterModule.forRoot(routes)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {
}

View File

@ -1,2 +1 @@
<app-hello-world></app-hello-world> <router-outlet></router-outlet>
<app-product-list-component></app-product-list-component>

View File

@ -3,16 +3,18 @@ import { NgModule } from '@angular/core';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { HelloWorldComponent } from './hello-world/hello-world.component'; import { HelloWorldComponent } from './hello-world/hello-world.component';
import { ProductListComponentComponent } from './product-list-component/product-list-component.component'; import { AppRoutingModule } from './app-routing.module';
import { ProductListComponent } from './product-list/product-list.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
HelloWorldComponent, HelloWorldComponent,
ProductListComponentComponent ProductListComponent
], ],
imports: [ imports: [
BrowserModule BrowserModule,
AppRoutingModule
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]

View File

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProductListComponentComponent } from './product-list-component.component';
describe('ProductListComponentComponent', () => {
let component: ProductListComponentComponent;
let fixture: ComponentFixture<ProductListComponentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProductListComponentComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ProductListComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,25 +0,0 @@
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'app-product-list-component',
templateUrl: './product-list-component.component.html',
styleUrls: ['./product-list-component.component.css']
})
export class ProductListComponentComponent implements OnInit {
testList: string[];
constructor() {
}
ngOnInit(): void {
this.testList = ['Herbert', 'Sascha', 'Rolf'];
}
// async function getCrypto(query: object): Promise<object> {
// const url = new URL('https://backend.betterzon.xyz');
// const headers = {};
// const response = await fetch(url.toString(), {headers});
// return await response.json();
// };
}

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProductListComponent } from './product-list.component';
describe('ProductListComponent', () => {
let component: ProductListComponent;
let fixture: ComponentFixture<ProductListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProductListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ProductListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,18 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-product-list',
templateUrl: './product-list.component.html',
styleUrls: ['./product-list.component.css']
})
export class ProductListComponent implements OnInit {
testList: string[];
constructor() {
}
ngOnInit(): void {
this.testList = ['Herbert', 'Sascha', 'Rolf'];
}
}