浏览代码

03-52 Added the ingredients

tags/before_ngrx
父节点
当前提交
043d95d3bb
共有 3 个文件被更改,包括 17 次插入1 次删除
  1. +3
    -0
      src/app/shared/ingredient.model.ts
  2. +9
    -1
      src/app/shopping-list/shopping-list.component.html
  3. +5
    -0
      src/app/shopping-list/shopping-list.component.ts

+ 3
- 0
src/app/shared/ingredient.model.ts 查看文件

@@ -0,0 +1,3 @@
export class Ingredient {
constructor(public name: string, public amount: number) {}
}

+ 9
- 1
src/app/shopping-list/shopping-list.component.html 查看文件

@@ -2,6 +2,14 @@
<div class="col-xs-10"> <div class="col-xs-10">
<app-shopping-edit></app-shopping-edit> <app-shopping-edit></app-shopping-edit>
<hr> <hr>
<p>The list</p>
<ul class="list-group">
<a
class="list-group-item"
style="cursor: pointer;"
*ngFor="let ingredient of ingredients"
>
{{ ingredient.name }} ({{ ingredient.amount }})
</a>
</ul>
</div> </div>
</div> </div>

+ 5
- 0
src/app/shopping-list/shopping-list.component.ts 查看文件

@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Ingredient } from '../shared/ingredient.model';


@Component({ @Component({
selector: 'app-shopping-list', selector: 'app-shopping-list',
@@ -6,6 +7,10 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./shopping-list.component.css'] styleUrls: ['./shopping-list.component.css']
}) })
export class ShoppingListComponent implements OnInit { export class ShoppingListComponent implements OnInit {
ingredients: Ingredient[] = [
new Ingredient('Apples', 5),
new Ingredient('Tomatos', 10)
];


constructor() { } constructor() { }




正在加载...
取消
保存