@ -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('formBuilder example', () => {
|
||||
@ -33,5 +34,4 @@ describe('formBuilder example', () => {
|
||||
inputs.get(0).sendKeys('a');
|
||||
expect(paragraphs.get(1).getText()).toEqual('Validation status: INVALID');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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
|
||||
|
@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
describe('nestedFormGroup example', () => {
|
||||
@ -40,5 +41,4 @@ describe('nestedFormGroup example', () => {
|
||||
expect(firstInput.getAttribute('value')).toEqual('Bess');
|
||||
expect(lastInput.getAttribute('value')).toEqual('Marvin');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgModule} from '@angular/core';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
|
@ -37,9 +37,13 @@ export class NestedFormGroupComp {
|
||||
email: new FormControl()
|
||||
});
|
||||
|
||||
get first(): any { return this.form.get('name.first'); }
|
||||
get first(): any {
|
||||
return this.form.get('name.first');
|
||||
}
|
||||
|
||||
get name(): any { return this.form.get('name'); }
|
||||
get name(): any {
|
||||
return this.form.get('name');
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
console.log(this.first.value); // 'Nancy'
|
||||
@ -48,6 +52,8 @@ export class NestedFormGroupComp {
|
||||
console.log(this.form.status); // VALID
|
||||
}
|
||||
|
||||
setPreset() { this.name.setValue({first: 'Bess', last: 'Marvin'}); }
|
||||
setPreset() {
|
||||
this.name.setValue({first: 'Bess', last: 'Marvin'});
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
@ -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('ngModelGroup example', () => {
|
||||
@ -38,5 +39,4 @@ describe('ngModelGroup example', () => {
|
||||
expect(inputs.get(0).getAttribute('value')).toEqual('Bess');
|
||||
expect(inputs.get(1).getAttribute('value')).toEqual('Marvin');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -37,6 +37,8 @@ export class NgModelGroupComp {
|
||||
console.log(f.valid); // true
|
||||
}
|
||||
|
||||
setValue() { this.name = {first: 'Bess', last: 'Marvin'}; }
|
||||
setValue() {
|
||||
this.name = {first: 'Bess', last: 'Marvin'};
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
@ -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('radioButtons example', () => {
|
||||
|
@ -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('radioButtons example', () => {
|
||||
|
@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementArrayFinder, ElementFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementArrayFinder, ElementFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
describe('reactiveSelectControl example', () => {
|
||||
@ -33,5 +34,4 @@ describe('reactiveSelectControl example', () => {
|
||||
|
||||
expect(p.getText()).toEqual('Form value: { "state": { "name": "Arizona", "abbrev": "AZ" } }');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementArrayFinder, ElementFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementArrayFinder, ElementFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
describe('selectControl example', () => {
|
||||
@ -22,8 +23,9 @@ describe('selectControl example', () => {
|
||||
p = element(by.css('p'));
|
||||
});
|
||||
|
||||
it('should initially select the placeholder option',
|
||||
() => { expect(options.get(0).getAttribute('selected')).toBe('true'); });
|
||||
it('should initially select the placeholder option', () => {
|
||||
expect(options.get(0).getAttribute('selected')).toBe('true');
|
||||
});
|
||||
|
||||
it('should update the model when the value changes in the UI', () => {
|
||||
select.click();
|
||||
@ -31,5 +33,4 @@ describe('selectControl example', () => {
|
||||
|
||||
expect(p.getText()).toEqual('Form value: { "state": { "name": "Arizona", "abbrev": "AZ" } }');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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('simpleForm example', () => {
|
||||
@ -40,5 +41,4 @@ describe('simpleForm example', () => {
|
||||
expect(paragraphs.get(1).getText()).toEqual('First name valid: true');
|
||||
expect(paragraphs.get(3).getText()).toEqual('Form valid: true');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
describe('simpleFormControl example', () => {
|
||||
@ -49,6 +50,5 @@ describe('simpleFormControl example', () => {
|
||||
element(by.css('button')).click();
|
||||
expect(input.getAttribute('value')).toEqual('new value');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -24,6 +24,8 @@ import {FormControl, Validators} from '@angular/forms';
|
||||
export class SimpleFormControl {
|
||||
control: FormControl = new FormControl('value', Validators.minLength(2));
|
||||
|
||||
setValue() { this.control.setValue('new value'); }
|
||||
setValue() {
|
||||
this.control.setValue('new value');
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
@ -6,7 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
describe('formControlName example', () => {
|
||||
@ -40,6 +41,5 @@ describe('formControlName example', () => {
|
||||
expect(firstInput.getAttribute('value')).toEqual('Carson');
|
||||
expect(lastInput.getAttribute('value')).toEqual('Drew');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -31,13 +31,17 @@ export class SimpleFormGroup {
|
||||
last: new FormControl('Drew'),
|
||||
});
|
||||
|
||||
get first(): any { return this.form.get('first'); }
|
||||
get first(): any {
|
||||
return this.form.get('first');
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
console.log(this.form.value); // {first: 'Nancy', last: 'Drew'}
|
||||
}
|
||||
|
||||
setValue() { this.form.setValue({first: 'Carson', last: 'Drew'}); }
|
||||
setValue() {
|
||||
this.form.setValue({first: 'Carson', last: 'Drew'});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ElementArrayFinder, ElementFinder, browser, by, element} from 'protractor';
|
||||
import {browser, by, element, ElementArrayFinder, ElementFinder} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
||||
|
||||
@ -42,5 +42,4 @@ describe('simpleNgModel example', () => {
|
||||
button.click();
|
||||
expect(input.getAttribute('value')).toEqual('Nancy');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -23,6 +23,8 @@ import {Component} from '@angular/core';
|
||||
export class SimpleNgModelComp {
|
||||
name: string = '';
|
||||
|
||||
setValue() { this.name = 'Nancy'; }
|
||||
setValue() {
|
||||
this.name = 'Nancy';
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
Reference in New Issue
Block a user