浏览代码

Commit before push to origin

tags/before_ngrx
父节点
当前提交
94465dc053
共有 3 个文件被更改,包括 32 次插入5 次删除
  1. +8
    -2
      src/app/recipes/recipe-detail/recipe-detail.component.html
  2. +5
    -1
      src/app/recipes/recipe.model.ts
  3. +19
    -2
      src/app/recipes/recipe.service.ts

+ 8
- 2
src/app/recipes/recipe-detail/recipe-detail.component.html 查看文件

@@ -17,7 +17,7 @@
Manage Recipe <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Add Ingredients</a></li>
<li><a (click)="onAddToShoppingList()" style="cursor: pointer;">Add Ingredients</a></li>
<li><a href="#">Edit Recipe</a></li>
<li><a href="#">Delete Recipe</a></li>
</ul>
@@ -31,6 +31,12 @@
</div>
<div class="row">
<div class="col-xs-12">
Ingredients
<ul class="list-group">
<li
class="list-group-item"
*ngFor="let ingredient of recipe.ingredients">
{{ ingredient.name }} - {{ ingredient.amount }}
</li>
</ul>
</div>
</div>

+ 5
- 1
src/app/recipes/recipe.model.ts 查看文件

@@ -1,11 +1,15 @@
import { Ingredient } from "../shared/ingredient.model";

export class Recipe {
public name: string;
public description: string;
public imagePath: string;
public ingredients: Ingredient[];

constructor(name: string, description: string, imagePath: string) {
constructor(name: string, description: string, imagePath: string, ingredients: Ingredient[]) {
this.name = name;
this.description = description;
this.imagePath = imagePath;
this.ingredients = ingredients;
}
}

+ 19
- 2
src/app/recipes/recipe.service.ts 查看文件

@@ -1,12 +1,29 @@
import { Recipe } from "./recipe.model";
import { EventEmitter } from "@angular/core";
import { Ingredient } from "../shared/ingredient.model";

export class RecipeService {
recipeSelected = new EventEmitter<Recipe>();

private recipes: Recipe[] = [
new Recipe('A Test Recipe', 'This is simlpy a test', 'http://maxpixel.freegreatpicture.com/static/photo/1x/Recipe-Soup-Noodle-Curried-Spicy-Chicken-Khaosoi-2344152.jpg'),
new Recipe('Another Test Recipe', 'This is simlpy a test', 'http://maxpixel.freegreatpicture.com/static/photo/1x/Recipe-Soup-Noodle-Curried-Spicy-Chicken-Khaosoi-2344152.jpg')
new Recipe(
'A Test Recipe',
'This is simlpy a test',
'http://maxpixel.freegreatpicture.com/static/photo/1x/Recipe-Soup-Noodle-Curried-Spicy-Chicken-Khaosoi-2344152.jpg',
[
new Ingredient('Foo', 1),
new Ingredient('Bar', 2)
]
),
new Recipe(
'Another Test Recipe',
'This is simlpy a test',
'http://maxpixel.freegreatpicture.com/static/photo/1x/Recipe-Soup-Noodle-Curried-Spicy-Chicken-Khaosoi-2344152.jpg',
[
new Ingredient('Foo', 1),
new Ingredient('Bar', 2)
]
)
];

getRecipes() {


正在加载...
取消
保存