Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
iteration 4 and half of bonus
  • Loading branch information
Georginapacey committed Sep 9, 2018
commit 82f625c914cb0280e3a02d7f82b129c0fcfc46cf
27 changes: 23 additions & 4 deletions starter-code/src/app/food-list/food-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@
<input type="text" class="form-control" placeholder="Search by title..." name="searchPattern" [(ngModel)]="searchPattern">
</div>
<div class="row">
<div *ngFor="let food of foods | foodFinder:searchPattern" class="col-4">
<img [src]="food.image" alt="">
<h4>{{food.name}}</h4>
<p>Calories: {{food.calories}}</p>
<div class="col-8">
<div class="row">
<div *ngFor="let food of foods | foodFinder:searchPattern" class="col-6">
<img [src]="food.image" alt="">
<h4>{{food.name}}</h4>
<p>Calories: {{food.calories}}</p>
<input type="number" placeholder="quantity" [(ngModel)]="food.quantity">
<button (click)="onClickAddFood(food)">Add</button>
</div>
</div>
</div>
<div class="col-4">
<div class="row">
<h4>Food for today:</h4>
<div>
<ul *ngFor="let selectedFood of selectedFoods">
<li>&nbsp;{{selectedFood.name}} x{{selectedFood.quantity}}</li>
</ul>
</div>
<div>
<p>total calories:</p>
</div>
</div>
</div>
</div>

Expand Down
9 changes: 9 additions & 0 deletions starter-code/src/app/food-list/food-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ import foods from '../foods';
export class FoodListComponent {
foods: Array<Food> = foods;
foodToCreate: Food = new Food();
selectedFoods: Array<Food> = [];
totalCalories: number = 0;


onClickCreateFood(): void {
this.foods.push(this.foodToCreate);
this.foodToCreate = new Food();
}

onClickAddFood(foodItem): void {
this.selectedFoods.push(foodItem);
}


}
4 changes: 4 additions & 0 deletions starter-code/src/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* You can add global styles to this file, and also import other style files */
img {
max-width: 100%;
}

h4 {
width: 100%;
}