@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementArrayFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementArrayFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
describe('nestedFormArray example', () => {
|
||||
@ -39,5 +40,4 @@ describe('nestedFormArray example', () => {
|
||||
expect(inputs.get(0).getAttribute('value')).toEqual('LA');
|
||||
expect(inputs.get(1).getAttribute('value')).toEqual('MTV');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -35,15 +35,21 @@ export class NestedFormArray {
|
||||
]),
|
||||
});
|
||||
|
||||
get cities(): FormArray { return this.form.get('cities') as FormArray; }
|
||||
get cities(): FormArray {
|
||||
return this.form.get('cities') as FormArray;
|
||||
}
|
||||
|
||||
addCity() { this.cities.push(new FormControl()); }
|
||||
addCity() {
|
||||
this.cities.push(new FormControl());
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
console.log(this.cities.value); // ['SF', 'NY']
|
||||
console.log(this.form.value); // { cities: ['SF', 'NY'] }
|
||||
}
|
||||
|
||||
setPreset() { this.cities.patchValue(['LA', 'MTV']); }
|
||||
setPreset() {
|
||||
this.cities.patchValue(['LA', 'MTV']);
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
Reference in New Issue
Block a user