Skip to content

Commit 28fd5f1

Browse files
committed
Update to match final course example.
1 parent 9461930 commit 28fd5f1

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

APM - Final/app/app.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
33
import { HttpModule } from '@angular/http';
4-
import { RouterModule} from '@angular/router';
4+
import { RouterModule } from '@angular/router';
55

66
import { AppComponent } from './app.component';
77
import { WelcomeComponent } from './home/welcome.component';
@@ -15,12 +15,15 @@ import { ProductModule } from './products/product.module';
1515
HttpModule,
1616
RouterModule.forRoot([
1717
{ path: 'welcome', component: WelcomeComponent },
18-
{ path: '', redirectTo: 'welcome', pathMatch: 'full'},
18+
{ path: '', redirectTo: 'welcome', pathMatch: 'full' },
1919
{ path: '**', redirectTo: 'welcome', pathMatch: 'full' }
2020
]),
2121
ProductModule
2222
],
23-
declarations: [ AppComponent, WelcomeComponent ],
23+
declarations: [
24+
AppComponent,
25+
WelcomeComponent
26+
],
2427
bootstrap: [ AppComponent ]
2528
})
2629
export class AppModule { }

APM - Final/app/products/product-filter.pipe.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { IProduct } from './product';
66
})
77
export class ProductFilterPipe implements PipeTransform {
88

9-
transform(value: IProduct[], filter: string): IProduct[] {
10-
filter = filter ? filter.toLocaleLowerCase() : null;
11-
return filter ? value.filter((product: IProduct) =>
12-
product.productName.toLocaleLowerCase().indexOf(filter) !== -1) : value;
9+
transform(value: IProduct[], filterBy: string): IProduct[] {
10+
filterBy = filterBy ? filterBy.toLocaleLowerCase() : null;
11+
return filterBy ? value.filter((product: IProduct) =>
12+
product.productName.toLocaleLowerCase().indexOf(filterBy) !== -1) : value;
1313
}
1414
}

APM - Final/app/products/product-list.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ <h3>Filtered by: {{listFilter}} </h3>
2020
<div class='has-error' *ngIf='errorMessage'>{{errorMessage}}</div>
2121

2222
<div class='table-responsive'>
23-
<table class='table' *ngIf='products && products.length'>
23+
<table class='table'
24+
*ngIf='products && products.length'>
2425
<thead>
2526
<tr>
2627
<th>
27-
<button class='btn btn-primary' (click)='toggleImage()'>
28+
<button class='btn btn-primary'
29+
(click)='toggleImage()'>
2830
{{showImage ? 'Hide' : 'Show'}} Image
2931
</button>
3032
</th>
@@ -44,7 +46,7 @@ <h3>Filtered by: {{listFilter}} </h3>
4446
[style.width.px]='imageWidth'
4547
[style.margin.px]='imageMargin'>
4648
</td>
47-
<td> <a [routerLink]="['/product', product.productId]">
49+
<td><a [routerLink]="['/product', product.productId]">
4850
{{product.productName}}
4951
</a>
5052
</td>

APM - Final/app/products/product-list.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export class ProductListComponent implements OnInit {
1212
imageWidth: number = 50;
1313
imageMargin: number = 2;
1414
showImage: boolean = false;
15-
listFilter: string = '';
15+
listFilter: string;
1616
errorMessage: string;
17+
1718
products: IProduct[];
1819

1920
constructor(private _productService: ProductService) {
@@ -26,9 +27,8 @@ export class ProductListComponent implements OnInit {
2627

2728
ngOnInit(): void {
2829
this._productService.getProducts()
29-
.subscribe(
30-
products => this.products = products,
31-
error => this.errorMessage = <any>error);
30+
.subscribe(products => this.products = products,
31+
error => this.errorMessage = <any>error);
3232
}
3333

3434
onRatingClicked(message: string): void {

APM - Final/app/shared/star.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="crop"
2-
[style.width.px]="starWidth"
3-
[title]='rating'
2+
[style.width.px]="starWidth"
3+
[title]="rating"
44
(click)='onClick()'>
55
<div style="width: 86px">
66
<span class="glyphicon glyphicon-star"></span>

APM - Final/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"postinstall": "typings install"
1414
},
1515
"license": "ISC",
16-
"dependencies": {
16+
"dependencies": {
1717
"@angular/common": "2.0.0",
1818
"@angular/compiler": "2.0.0",
1919
"@angular/core": "2.0.0",

0 commit comments

Comments
 (0)