在我的组件中,我得到了一个我在模板中显示的任务列表,如下所示:
<mdl-expansion-panel-group>
<mdl-expansion-panel *ngFor="let task of tasks">
<mdl-expansion-panel-header>
<mdl-expansion-panel-header-list-content><h6>{{task.what_task}}</h6></mdl-expansion-panel-header-list-content>
</mdl-expansion-panel-header>
<mdl-expansion-panel-content>
<mdl-expansion-panel-body>
<form [formGroup]="form">
<!-- What task -->
<p>
<mdl-textfield label="What task" type="text" formControlName="what_task" floating-label [ngModel]="task.what_task"></mdl-textfield>
</p>
<!-- How often -->
<p>
How often do you perform?<br/>
<mdl-radio value="Daily" formControlName="how_often" mdl-ripple [ngModel]="task.how_often">Daily once</mdl-radio>
<mdl-radio value="Weekly" formControlName="how_often" mdl-ripple [ngModel]="task.how_often">Weekly once</mdl-radio>
</p><br>
<p>
<button mdl-button (click)="updateTask(task, task.id)" [disabled]="!form.valid" mdl-button-type="raised" mdl-ripple mdl-colored="primary">Submit</button>
</p>
</form>
</mdl-expansion-panel-body>
</mdl-expansion-panel-content>
</mdl-expansion-panel>
</mdl-expansion-panel-group>
我的想法是,我将任务视为面板,我可以扩展单个面板以编辑该特定任务。
我面临两个问题: