diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..18e4419 --- /dev/null +++ b/.vscode/launch.json @@ -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", + "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" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..550cb18 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,34 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "start", + "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." + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/app/product-list/product-list.component.css b/src/app/product-list/product-list.component.css index e69de29..f7ee0fd 100644 --- a/src/app/product-list/product-list.component.css +++ b/src/app/product-list/product-list.component.css @@ -0,0 +1,8 @@ +.strike-through { + text-decoration: line-through; +} + +.my-7 { + margin-top: 0.02%; + margin-bottom: 14px; +} \ No newline at end of file diff --git a/src/app/product-list/product-list.component.html b/src/app/product-list/product-list.component.html index b760f69..c877c58 100644 --- a/src/app/product-list/product-list.component.html +++ b/src/app/product-list/product-list.component.html @@ -14,6 +14,23 @@

Description: {{ product.description }}

+
+

+ Was: + {{ product.originalPrice | currency }} +

+
+ Now: + {{ product.price | currency }} +
+
+ + +

+ Price: {{ product.price | currency }} +

+
+ diff --git a/src/app/product-list/product-list.component.ts b/src/app/product-list/product-list.component.ts index eb746cf..70741e9 100644 --- a/src/app/product-list/product-list.component.ts +++ b/src/app/product-list/product-list.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; -import { products } from '../products'; +import { Product, products } from '../products'; @Component({ selector: 'app-product-list', @@ -9,7 +9,7 @@ import { products } from '../products'; }) export class ProductListComponent { - products = [...products]; + products: Product[] = [...products]; share() { window.alert('The product has been shared!'); diff --git a/src/app/products.ts b/src/app/products.ts index 4d99807..a8dba3a 100644 --- a/src/app/products.ts +++ b/src/app/products.ts @@ -3,6 +3,8 @@ export interface Product { name: string; price: number; description: string; + onSale: boolean; + originalPrice?: number; } export const products: Product[] = [ @@ -10,18 +12,22 @@ 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 } ];