refactor: move angular source to /packages rather than modules/@angular
This commit is contained in:
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @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 {ElementArrayFinder, browser, by, element} from 'protractor';
|
||||
import {verifyNoBrowserErrors} from '../../../../_common/e2e_util';
|
||||
|
||||
describe('radioButtons example', () => {
|
||||
afterEach(verifyNoBrowserErrors);
|
||||
let inputs: ElementArrayFinder;
|
||||
|
||||
beforeEach(() => {
|
||||
browser.get('/forms/ts/reactiveRadioButtons/index.html');
|
||||
inputs = element.all(by.css('input'));
|
||||
});
|
||||
|
||||
it('should populate the UI with initial values', () => {
|
||||
expect(inputs.get(0).getAttribute('checked')).toEqual(null);
|
||||
expect(inputs.get(1).getAttribute('checked')).toEqual('true');
|
||||
expect(inputs.get(2).getAttribute('checked')).toEqual(null);
|
||||
|
||||
expect(element(by.css('p')).getText()).toEqual('Form value: { "food": "lamb" }');
|
||||
});
|
||||
|
||||
it('update model and other buttons as the UI value changes', () => {
|
||||
inputs.get(0).click();
|
||||
|
||||
expect(inputs.get(0).getAttribute('checked')).toEqual('true');
|
||||
expect(inputs.get(1).getAttribute('checked')).toEqual(null);
|
||||
expect(inputs.get(2).getAttribute('checked')).toEqual(null);
|
||||
|
||||
expect(element(by.css('p')).getText()).toEqual('Form value: { "food": "beef" }');
|
||||
});
|
||||
});
|
20
packages/examples/forms/ts/reactiveRadioButtons/module.ts
Normal file
20
packages/examples/forms/ts/reactiveRadioButtons/module.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {ReactiveRadioButtonComp} from './reactive_radio_button_example';
|
||||
|
||||
@NgModule({
|
||||
imports: [BrowserModule, ReactiveFormsModule],
|
||||
declarations: [ReactiveRadioButtonComp],
|
||||
bootstrap: [ReactiveRadioButtonComp]
|
||||
})
|
||||
export class AppModule {
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// #docregion Reactive
|
||||
import {Component} from '@angular/core';
|
||||
import {FormControl, FormGroup} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'example-app',
|
||||
template: `
|
||||
<form [formGroup]="form">
|
||||
<input type="radio" formControlName="food" value="beef" > Beef
|
||||
<input type="radio" formControlName="food" value="lamb"> Lamb
|
||||
<input type="radio" formControlName="food" value="fish"> Fish
|
||||
</form>
|
||||
|
||||
<p>Form value: {{ form.value | json }}</p> <!-- {food: 'lamb' } -->
|
||||
`,
|
||||
})
|
||||
export class ReactiveRadioButtonComp {
|
||||
form = new FormGroup({
|
||||
food: new FormControl('lamb'),
|
||||
});
|
||||
}
|
||||
// #enddocregion
|
Reference in New Issue
Block a user