|
|
@ -1,5 +1,5 @@ |
|
|
|
import { Component } from '@angular/core'; |
|
|
|
import { FormControl, FormGroup } from '@angular/forms'; |
|
|
|
import { FormArray, FormControl, FormGroup } from '@angular/forms'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@ -9,8 +9,20 @@ import { FormControl, FormGroup } from '@angular/forms'; |
|
|
|
}) |
|
|
|
export class AppComponent { |
|
|
|
readonly form = new FormGroup({ |
|
|
|
id:new FormControl(), |
|
|
|
password: new FormControl(), |
|
|
|
Tasks: new FormArray([]), |
|
|
|
}); |
|
|
|
|
|
|
|
get tasks(): FormArray{ |
|
|
|
return this.form.get('Tasks') as FormArray; |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit(): void{ |
|
|
|
this.tasks.push(//注意此push用法
|
|
|
|
new FormGroup({ |
|
|
|
Subject: new FormControl(), |
|
|
|
Content: new FormControl(), |
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |