Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // profile.component.ts
- ruleList: Array<any>;
- profileForm = new FormGroup({
- firstName: new FormControl(''),
- lastName: new FormControl(''),
- rules: new FormArray([])
- });
- initForm() {
- this.store.select('profile').subscribe(profile => {
- profile.rules.forEach(rule => {
- const ruleList = this.profileForm.get('rules') as FormArray;
- ruleList.push(new FormControl(rule));
- });
- });
- this.store.select('profileRules').subscribe(rules => {
- rules.forEach(rule => {
- this.ruleList.push(rule);
- });
- });
- }
- // profile.component.html
- <!!=*==>
- <input type="checkbox" [formControlName]="i"> {{ruleList[i].name}}
- </label>
- lub
- <label formArrayName="rules" *ngFor="let rule of (profileRules$ | async).list; let i = index">
- <input type="checkbox" [formControlName]="i"> {{rule.name}}
- </label>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement