Angular - @Input, @output, ngFor和ngIf

  • 780
  • 0
  • 2018-05-15

實現@Input, @output, ngFor和ngIf 四個功能

情境說明:

在app.component.ts 內定義要提供其他Component共用的 物件(TodoItem)陣列 :todoItmes,

把這個物件傳遞到 component :todo-items 讓他呈現在畫面上,

在component :todo-items 畫面上操作刪除的時候,

要binding 回 app.component.ts內提供的Function 將app.component.ts內定義的物件陣列內的值給移除

最後,透過add-form.component.ts 畫面上的新增對話框可以新增TodoItem至 app.component.ts內的物件陣列

實際新增的動作一樣是由 app.component.ts 提供。

...繼續閱讀 »