From 951fb792a342f38bea1760c5104e9f844ac7d49c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 20 Dec 2019 16:13:25 +0100 Subject: [PATCH] =?utf8?q?Product-List=20aus=20Tutorial=20=C3=BCbernommen?= =?utf8?q?=20(direkt=20mit=20Erweiterungen)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/app/app.component.html | 2 +- src/app/app.module.ts | 5 +++- .../product-list/product-list.component.css | 0 .../product-list/product-list.component.html | 14 +++++++++++ .../product-list.component.spec.ts | 25 +++++++++++++++++++ .../product-list/product-list.component.ts | 15 +++++++++++ src/app/products.ts | 17 +++++++++++++ 7 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/app/product-list/product-list.component.css create mode 100644 src/app/product-list/product-list.component.html create mode 100644 src/app/product-list/product-list.component.spec.ts create mode 100644 src/app/product-list/product-list.component.ts create mode 100644 src/app/products.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index e7d2b67..0a4efe3 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@
-

Hallo Welt!

+
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d6559fb..4cd6aea 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -4,15 +4,18 @@ import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; import { TopBarComponent } from './top-bar/top-bar.component'; +import { ProductListComponent } from './product-list/product-list.component'; @NgModule({ declarations: [ AppComponent, - TopBarComponent + TopBarComponent, + ProductListComponent ], imports: [ BrowserModule, RouterModule.forRoot([ + { path: '', component: ProductListComponent } ]) ], providers: [], diff --git a/src/app/product-list/product-list.component.css b/src/app/product-list/product-list.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/product-list/product-list.component.html b/src/app/product-list/product-list.component.html new file mode 100644 index 0000000..91c9aea --- /dev/null +++ b/src/app/product-list/product-list.component.html @@ -0,0 +1,14 @@ +

Products

+ +
+ +

+ {{ product.name }} +

+

Description: {{ product.description }}

+

{{ product.price }} €

+ + +
diff --git a/src/app/product-list/product-list.component.spec.ts b/src/app/product-list/product-list.component.spec.ts new file mode 100644 index 0000000..a2c901b --- /dev/null +++ b/src/app/product-list/product-list.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProductListComponent } from './product-list.component'; + +describe('ProductListComponent', () => { + let component: ProductListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProductListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProductListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/product-list/product-list.component.ts b/src/app/product-list/product-list.component.ts new file mode 100644 index 0000000..a66ea2e --- /dev/null +++ b/src/app/product-list/product-list.component.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; + +import { products } from '../products'; + +@Component({ + templateUrl: './product-list.component.html', + styleUrls: ['./product-list.component.css'] +}) +export class ProductListComponent { + products = products; + + share() { + window.alert('The product has been pimmelled!'); + } +} diff --git a/src/app/products.ts b/src/app/products.ts new file mode 100644 index 0000000..998c38d --- /dev/null +++ b/src/app/products.ts @@ -0,0 +1,17 @@ +export const products = [ + { + name: 'Phone XXL', + price: 799, + description: 'A large phone with one of the best screens' + }, + { + name: 'Phone Minion', + price: 699, + description: 'A great phone with one of the best cameras' + }, + { + name: 'Pimmel-Phone', + price: 299, + description: '' + } +]; -- 2.20.1