New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forms): add easy way to switch between forms modules #9202

Merged
merged 1 commit into from Jun 15, 2016

Conversation

Projects
None yet
5 participants
@kara
Contributor

kara commented Jun 15, 2016

This PR:

  • creates a separate module for the new forms work at @angular/forms
  • keeps the original forms code in @angular/common
  • sets a console warning if you are still using the old forms module
  • provides two helper functions to switch platform directives from the old to new forms code
  • runs @angular/forms integration tests along with original @angular/common tests for forms.

This PR contains no breaking changes. To continue to use the original forms module, no changes are currently required.

To check out the new forms code, you must do the following in your bootstrap file:

main.ts

import {disableDeprecatedForms, provideForms} from '@angular/forms';

bootstrap(AppComponent, [
   disableDeprecatedForms(),
   provideForms()
])

Then, if you want to use any symbols from the new setup (like FormGroup or REACTIVE_FORM_DIRECTIVES), simply import from @angular/forms rather than @angular/common.

You can see more about the new forms API updates here:
https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub

@robwormald

This comment has been minimized.

Member

robwormald commented Jun 15, 2016

LGTM 👍

@robwormald robwormald merged commit 22916bb into angular:master Jun 15, 2016

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@@ -95,6 +95,11 @@ export class NgForm extends ControlContainer implements Form {
@Optional() @Self() @Inject(NG_VALIDATORS) validators: any[],
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) asyncValidators: any[]) {
super();
console.warn(`

This comment has been minimized.

@vicb

vicb Jun 15, 2016

Contributor

@kara could you make sure the error is printed only once so that the test logs are not full of warnings ?

This comment has been minimized.

@kara

kara Jun 15, 2016

Contributor

Eesh. We can't really stop running those old tests, and it's doing what it's supposed to by logging once per form... Maybe I can set up an override for the tests. On it.

This comment has been minimized.

@vicb

vicb Jun 15, 2016

Contributor

if (!_displayed) { _displayed = true; console.log() }

should work ?

This comment has been minimized.

@kara

kara Jun 15, 2016

Contributor

You mean not on the instance level? That should work.

This comment has been minimized.

@vicb

vicb Jun 15, 2016

Contributor

file level, yes

@ThomasBurleson

This comment has been minimized.

ThomasBurleson commented Jun 20, 2016

@kara - love the effort you invested in the PR body area to explain the PR. Thank you!

@kara kara added the comp: forms label Sep 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment