angular-docs-cn/modules
Kara 9d265b6f61 feat(forms): add modules for forms and deprecatedForms (#9859)
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
```
2016-07-07 11:32:51 -07:00
..
@angular feat(forms): add modules for forms and deprecatedForms (#9859) 2016-07-07 11:32:51 -07:00
angular1_router fix(ngRouteShim): update anchors to function similar to angular 1.x (#8478) 2016-05-26 12:03:23 -07:00
benchmarks feat(benchpress): add custom user metric to benchpress 2016-06-16 07:30:53 -07:00
benchmarks_external repackaging: all the repackaging changes squashed 2016-05-01 20:51:00 -07:00
benchpress feat(benchpress): add custom user metric to benchpress 2016-06-16 07:30:53 -07:00
payload_tests/hello_world/ts repackaging: all the repackaging changes squashed 2016-05-01 20:51:00 -07:00
playground refactor(router): clean up naming 2016-07-06 16:19:52 -07:00
rollup-test build: remove dependency on tsd and use @types/* instead 2016-05-25 16:42:28 -07:00
empty.ts chore(lint): Added license headers to most TypeScript files 2016-06-23 09:47:54 -07:00
es6-subset.d.ts chore(typings): restrict Angular to es5+collections+promise 2016-06-27 13:58:59 -07:00
tsconfig-ts2dart.json repackaging: all the repackaging changes squashed 2016-05-01 20:51:00 -07:00
tsconfig.json chore(typings): restrict Angular to es5+collections+promise 2016-06-27 13:58:59 -07:00
types.d.ts chore(typings): restrict Angular to es5+collections+promise 2016-06-27 13:58:59 -07:00
upgrade-ts2dart.d.ts repackaging: all the repackaging changes squashed 2016-05-01 20:51:00 -07:00
zone-ts2dart.d.ts repackaging: all the repackaging changes squashed 2016-05-01 20:51:00 -07:00