
Closes #9732 BREAKING CHANGE: We have removed the deprecated form directives from the built-in platform directive list, so apps are not required to package forms with their app. This also makes forms friendly to offline compilation. Instead, we have exposed three modules: OLD API: - `DeprecatedFormsModule` NEW API: - `FormsModule` - `ReactiveFormsModule` If you provide one of these modules, the default forms directives and providers from that module will be available to you app-wide. Note: You can provide both the `FormsModule` and the `ReactiveFormsModule` together if you like, but they are fully-functional separately. **Before:** ```ts import {disableDeprecatedForms, provideForms} from @angular/forms; bootstrap(App, [ disableDeprecatedForms(), provideForms() ]); ``` **After:** ```ts import {DeprecatedFormsModule} from @angular/common; bootstrap(App, {modules: [DeprecatedFormsModule] }); ``` -OR- ```ts import {FormsModule} from @angular/forms; bootstrap(App, {modules: [FormsModule] }); ``` -OR- ```ts import {ReactiveFormsModule} from @angular/forms; bootstrap(App, {modules: [ReactiveFormsModule] }); ``` You can also choose not to provide any forms module and run your app without forms. Or you can choose not to provide any forms module *and* provide form directives at will. This will allow you to use the deprecatedForms API for some components and not others. ``` import {FORM_DIRECTIVES, FORM_PROVIDERS} from @angular/forms; @Component({ selector: some-comp, directives: [FORM_DIRECTIVES], providers: [FORM_PROVIDERS] }) class SomeComp ```
76 lines
3.0 KiB
TypeScript
76 lines
3.0 KiB
TypeScript
/**
|
|
* @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
|
|
*/
|
|
|
|
/**
|
|
* @module
|
|
* @description
|
|
* This module is used for handling user input, by defining and building a {@link ControlGroup} that
|
|
* consists of
|
|
* {@link Control} objects, and mapping them onto the DOM. {@link Control} objects can then be used
|
|
* to read information
|
|
* from the form DOM elements.
|
|
*
|
|
* Forms providers are not included in default providers; you must import these providers
|
|
* explicitly.
|
|
*/
|
|
import {AppModule, Type} from '@angular/core';
|
|
|
|
import {FORM_DIRECTIVES} from './forms-deprecated/directives';
|
|
import {RadioControlRegistry} from './forms-deprecated/directives/radio_control_value_accessor';
|
|
import {FormBuilder} from './forms-deprecated/form_builder';
|
|
|
|
export {FORM_DIRECTIVES, RadioButtonState} from './forms-deprecated/directives';
|
|
export {AbstractControlDirective} from './forms-deprecated/directives/abstract_control_directive';
|
|
export {CheckboxControlValueAccessor} from './forms-deprecated/directives/checkbox_value_accessor';
|
|
export {ControlContainer} from './forms-deprecated/directives/control_container';
|
|
export {ControlValueAccessor, NG_VALUE_ACCESSOR} from './forms-deprecated/directives/control_value_accessor';
|
|
export {DefaultValueAccessor} from './forms-deprecated/directives/default_value_accessor';
|
|
export {Form} from './forms-deprecated/directives/form_interface';
|
|
export {NgControl} from './forms-deprecated/directives/ng_control';
|
|
export {NgControlGroup} from './forms-deprecated/directives/ng_control_group';
|
|
export {NgControlName} from './forms-deprecated/directives/ng_control_name';
|
|
export {NgControlStatus} from './forms-deprecated/directives/ng_control_status';
|
|
export {NgForm} from './forms-deprecated/directives/ng_form';
|
|
export {NgFormControl} from './forms-deprecated/directives/ng_form_control';
|
|
export {NgFormModel} from './forms-deprecated/directives/ng_form_model';
|
|
export {NgModel} from './forms-deprecated/directives/ng_model';
|
|
export {NgSelectOption, SelectControlValueAccessor} from './forms-deprecated/directives/select_control_value_accessor';
|
|
export {MaxLengthValidator, MinLengthValidator, PatternValidator, RequiredValidator, Validator} from './forms-deprecated/directives/validators';
|
|
export {FormBuilder} from './forms-deprecated/form_builder';
|
|
export {AbstractControl, Control, ControlArray, ControlGroup} from './forms-deprecated/model';
|
|
export {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from './forms-deprecated/validators';
|
|
|
|
|
|
/**
|
|
* Shorthand set of providers used for building Angular forms.
|
|
*
|
|
* ### Example
|
|
*
|
|
* ```typescript
|
|
* bootstrap(MyApp, [FORM_PROVIDERS]);
|
|
* ```
|
|
*
|
|
* @experimental
|
|
*/
|
|
export const FORM_PROVIDERS: Type[] = /*@ts2dart_const*/[FormBuilder, RadioControlRegistry];
|
|
|
|
|
|
/**
|
|
* The app module for the deprecated forms API.
|
|
* @deprecated
|
|
*/
|
|
@AppModule({
|
|
providers: [
|
|
FORM_PROVIDERS,
|
|
],
|
|
directives: FORM_DIRECTIVES,
|
|
pipes: []
|
|
})
|
|
export class DeprecatedFormsModule {
|
|
}
|