Skip to content

Commit a5638a9

Browse files
feat(directives): export collection of core directives
Closes #1524
1 parent 4665726 commit a5638a9

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

Diff for: modules/angular2/directives.js

+51-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,61 @@
22
* @module
33
* @public
44
* @description
5-
* Common directives shipped with Angualr.
5+
* Common directives shipped with Angular.
66
*/
77

8+
import {CONST_EXPR} from './src/facade/lang';
9+
import {For} from './src/directives/for';
10+
import {If} from './src/directives/if';
11+
import {NonBindable} from './src/directives/non_bindable';
12+
import {Switch, SwitchWhen, SwitchDefault} from './src/directives/switch';
13+
814
export * from './src/directives/class';
915
export * from './src/directives/for';
1016
export * from './src/directives/if';
1117
export * from './src/directives/non_bindable';
1218
export * from './src/directives/switch';
19+
20+
/**
21+
* A collection of the Angular core directives that are likely to be used in each and every Angular application.
22+
*
23+
* This collection can be used to quickly enumerate all the built-in directives in the `@View` annotation. For example,
24+
* instead of writing:
25+
*
26+
* ```
27+
* import {If, For, Switch, SwitchWhen, SwitchDefault} from 'angular2/angular2';
28+
* import {OtherDirective} from 'myDirectives';
29+
*
30+
* @Component({
31+
* selector: 'my-component'
32+
* })
33+
* @View({
34+
* templateUrl: 'myComponent.html',
35+
* directives: [If, For, Switch, SwitchWhen, SwitchDefault, OtherDirective]
36+
* })
37+
* export class MyComponent {
38+
* ...
39+
* }
40+
* ```
41+
* one could enumerate all the core directives at once:
42+
*
43+
** ```
44+
* import {coreDirectives} from 'angular2/angular2';
45+
* import {OtherDirective} from 'myDirectives';
46+
*
47+
* @Component({
48+
* selector: 'my-component'
49+
* })
50+
* @View({
51+
* templateUrl: 'myComponent.html',
52+
* directives: [coreDirectives, OtherDirective]
53+
* })
54+
* export class MyComponent {
55+
* ...
56+
* }
57+
* ```
58+
*
59+
*/
60+
export const coreDirectives:List = CONST_EXPR([
61+
For, If, NonBindable, Switch, SwitchWhen, SwitchDefault
62+
]);

0 commit comments

Comments
 (0)