-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the ability to auto import typescript in cqmd
- Loading branch information
Showing
3 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Component, EventEmitter, Input, Output } from "@angular/core"; | ||
import { Product } from "../product.model"; | ||
|
||
/** | ||
* @ProductsList: A component for rendering all ProductRows and | ||
* storing the currently selected Product | ||
*/ | ||
@Component({ | ||
selector: "products-list", | ||
templateUrl: "./products-list.component.html" | ||
}) | ||
export class ProductsListComponent { | ||
/** | ||
* @input productList - the Product[] passed to us | ||
*/ | ||
@Input() productList: Product[]; | ||
|
||
/** | ||
* @output onProductSelected - outputs the current | ||
* Product whenever a new Product is selected | ||
*/ | ||
@Output() onProductSelected: EventEmitter<Product>; | ||
|
||
/** | ||
* @property currentProduct - local state containing | ||
* the currently selected `Product` | ||
*/ | ||
private currentProduct: Product; | ||
|
||
constructor() { | ||
this.onProductSelected = new EventEmitter(); | ||
} | ||
|
||
clicked(product: Product): void { | ||
this.currentProduct = product; | ||
this.onProductSelected.emit(product); | ||
} | ||
|
||
isSelected(product: Product): boolean { | ||
if (!product || !this.currentProduct) { | ||
return false; | ||
} | ||
return product.sku === this.currentProduct.sku; | ||
} | ||
} |