Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"url": "http://localhost:4200",
"url": "http://localhost:4201",

"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"preLaunchTask": "start"
},
{
"type": "msedge",
"request": "launch",
"name": "Launch Edge against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"preLaunchTask": "start"
}
]
}
34 changes: 34 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "start",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the linter to correct this whitespace

"type": "npm",
"script": "start",
"isBackground": true,
"presentation": {
"focus": true,
"panel": "dedicated"
},
"problemMatcher": {
"owner": "typescript",
"source": "ts",
"applyTo": "closedDocuments",
"fileLocation": [
"relative",
"${cwd}"
],
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "Compiled |Failed to compile."
}
}
}
}
]
}
8 changes: 8 additions & 0 deletions src/app/product-list/product-list.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.strike-through {
text-decoration: line-through;
}

.my-7 {
margin-top: 0.02%;
margin-bottom: 14px;
}
17 changes: 17 additions & 0 deletions src/app/product-list/product-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ <h3>
Description: {{ product.description }}
</p>

<div *ngIf="product.onSale; else normalPrice" class="my-7">
<p>
<span>Was: </span>
<span class="strike-through"> {{ product.originalPrice | currency }} </span>
</p>
<div>
<span>Now: </span>
<span> {{ product.price | currency }} </span>
</div>
</div>

<ng-template #normalPrice>
<p>
Price: {{ product.price | currency }}
</p>
</ng-template>

<button type="button" (click)="share()">
Share
</button>
Expand Down
4 changes: 2 additions & 2 deletions src/app/product-list/product-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';

import { products } from '../products';
import { Product, products } from '../products';

@Component({
selector: 'app-product-list',
Expand All @@ -9,7 +9,7 @@ import { products } from '../products';
})
export class ProductListComponent {

products = [...products];
products: Product[] = [...products];

share() {
window.alert('The product has been shared!');
Expand Down
12 changes: 9 additions & 3 deletions src/app/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@ export interface Product {
name: string;
price: number;
description: string;
onSale: boolean;
originalPrice?: number;
}

export const products: Product[] = [
{
id: 1,
name: 'Phone XL',
price: 799,
description: 'A large phone with one of the best screens'
description: 'A large phone with one of the best screens',
onSale: false
},
{
id: 2,
name: 'Phone Mini',
price: 699,
description: 'A great phone with one of the best cameras'
description: 'A great phone with one of the best cameras',
onSale: false
},
{
id: 3,
name: 'Phone Standard',
price: 299,
description: ''
description: '',
onSale: true,
originalPrice: 500
}
];