Skip to content

Commit 22916bb

Browse files
kararobwormald
authored andcommitted
feat(forms): add easy way to switch between forms modules (angular#9202)
1 parent fe01e2e commit 22916bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3570
-583
lines changed

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ for PACKAGE in \
4444
core \
4545
compiler \
4646
common \
47+
forms \
4748
platform-browser \
4849
platform-browser-dynamic \
4950
platform-server \

modules/@angular/common/src/forms-deprecated/directives/ng_form.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ export class NgForm extends ControlContainer implements Form {
9595
@Optional() @Self() @Inject(NG_VALIDATORS) validators: any[],
9696
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) asyncValidators: any[]) {
9797
super();
98+
console.warn(`
99+
*It looks like you're using the old forms module. This will be opt-in in the next RC, and
100+
will eventually be removed in favor of the new forms module. For more information, see:
101+
https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub
102+
`);
98103
this.form = new ControlGroup(
99104
{}, null, composeValidators(validators), composeAsyncValidators(asyncValidators));
100105
}

modules/@angular/common/src/forms-deprecated/directives/ng_form_model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ export class NgFormModel extends ControlContainer implements Form,
113113
@Optional() @Self() @Inject(NG_VALIDATORS) private _validators: any[],
114114
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) private _asyncValidators: any[]) {
115115
super();
116+
console.warn(`
117+
*It looks like you're using the old forms module. This will be opt-in in the next RC, and
118+
will eventually be removed in favor of the new forms module. For more information, see:
119+
https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub
120+
`);
116121
}
117122

118123
ngOnChanges(changes: SimpleChanges): void {

modules/@angular/common/src/forms.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

modules/@angular/core/core.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export './src/core/debug/debug_node.dart' show DebugElement,
2121
asNativeElements;
2222
export './src/core/testability/testability.dart';
2323
export './src/core/change_detection.dart';
24+
export './src/core/platform_directives_and_pipes.dart';
2425
export './src/core/platform_common_providers.dart';
2526
export './src/core/application_common_providers.dart';
2627
export './src/core/reflection/reflection.dart';

modules/@angular/core/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './src/linker';
1414
export {DebugElement, DebugNode, asNativeElements, getDebugNode} from './src/debug/debug_node';
1515
export * from './src/testability/testability';
1616
export * from './src/change_detection';
17+
export * from './src/platform_directives_and_pipes';
1718
export * from './src/platform_common_providers';
1819
export * from './src/application_common_providers';
1920
export {wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, WtfScopeFn} from './src/profile/profile';
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import {OpaqueToken} from './di';
2+
3+
/**
4+
A token that can be provided when bootstrapping an application to make an array of directives
5+
* available in every component of the application.
6+
*
7+
* ### Example
8+
*
9+
* ```typescript
10+
* import {PLATFORM_DIRECTIVES} from '@angular/core';
11+
* import {OtherDirective} from './myDirectives';
12+
*
13+
* @Component({
14+
* selector: 'my-component',
15+
* template: `
16+
* <!-- can use other directive even though the component does not list it in `directives` -->
17+
* <other-directive></other-directive>
18+
* `
19+
* })
20+
* export class MyComponent {
21+
* ...
22+
* }
23+
*
24+
* bootstrap(MyComponent, [{provide: PLATFORM_DIRECTIVES, useValue: [OtherDirective],
25+
multi:true}]);
26+
* ```
27+
* @stable
28+
*/
29+
30+
export const PLATFORM_DIRECTIVES: OpaqueToken =
31+
/*@ts2dart_const*/ new OpaqueToken('Platform Directives');
32+
33+
/**
34+
* A token that can be provided when bootstraping an application to make an array of pipes
35+
* available in every component of the application.
36+
*
37+
* ### Example
38+
*
39+
* ```typescript
40+
* import {PLATFORM_PIPES} from '@angular/core';
41+
* import {OtherPipe} from './myPipe';
42+
*
43+
* @Component({
44+
* selector: 'my-component',
45+
* template: `
46+
* {{123 | other-pipe}}
47+
* `
48+
* })
49+
* export class MyComponent {
50+
* ...
51+
* }
52+
*
53+
* bootstrap(MyComponent, [{provide: PLATFORM_PIPES, useValue: [OtherPipe], multi:true}]);
54+
* ```
55+
* @stable
56+
*/
57+
58+
export const PLATFORM_PIPES: OpaqueToken = /*@ts2dart_const*/ new OpaqueToken('Platform Pipes');

modules/@angular/forms/common.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export 'index.dart';

modules/@angular/forms/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './src/forms';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@angular/forms",
3+
"version": "0.0.0-PLACEHOLDER",
4+
"description": "",
5+
"main": "index.js",
6+
"jsnext:main": "esm/index.js",
7+
"typings": "index.d.ts",
8+
"author": "angular",
9+
"license": "MIT",
10+
"peerDependencies": {
11+
"@angular/core": "0.0.0-PLACEHOLDER",
12+
"@angular/common": "0.0.0-PLACEHOLDER",
13+
"@angular/compiler": "0.0.0-PLACEHOLDER"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/angular/angular.git"
18+
}
19+
}

0 commit comments

Comments
 (0)