1
1
/**
2
2
* Bootstrapping for Angular applications via [app:dynamic] (#angular-app-dynamic) for development,
3
- * or
4
- * [app:static] (#angular-app-static) for production.
3
+ * or [app:static] (#angular-app-static) for production.
5
4
*
5
+ * In your `main()` function, you bootstrap Angular by explicitly defining and adding a module for
6
+ * your app:
7
+ *
8
+ * import 'package:angular/angular.dart';
9
+ * import 'package:angular/angular_dynamic.dart';
10
+ *
11
+ * class MyModule extends Module {
12
+ * MyModule() {
13
+ * type(HelloWorldController);
14
+ * }
15
+ * }
16
+ *
17
+ * main() {
18
+ * dynamicApplication()
19
+ * .addModule(new MyModule())
20
+ * .run();
21
+ * }
22
+ *
23
+ * In the code above, we use [dynamicApplication] (#angular-app-dynamic) to
24
+ * take advantage of [dart:mirrors]
25
+ * (https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-mirrors) during
26
+ * development. When you run the app in Dartium, you are using the implementation found under
27
+ * [app:dynamic] (#angular-app-dynamic). Note also that you must explicitly import both
28
+ * `angular.dart` and `angular_dynamic.dart` at the start of your file.
29
+ *
30
+ * For production, transformers defined in your `pubspec.yaml` file convert the compiled code to
31
+ * use the [app:static] (#angular-app-static) implementation when you run `pub build` . Instead of
32
+ * relying on mirrors, this automatically generates the getters, setters, annotations, and factories
33
+ * needed by Dart for tree shaking in dart2js, ensuring that your final JavaScript code contains
34
+ * only what is used by the root Injector that ngApp creates.
35
+ *
36
+ * Add the transformers rule shown below to your `pubspec.yaml` :
37
+ *
38
+ * name: angular_dart_example
39
+ * version: 0.0.1
40
+ * dependencies:
41
+ * angular: '>= 0.9.11'
42
+ * browser: any
43
+ * unittest: any
44
+ *
45
+ * transformers:
46
+ * - angular
47
+ *
48
+ * If your app structure makes use of directories for storing your templates,
49
+ * you must also specify rules for `html_files` to ensure that the transformers pick up those
50
+ * files. You only need to specify the HTML files; the parser will infer the correct `.dart` and
51
+ * CSS files to include.
52
+ *
53
+ * For example:
54
+ *
55
+ * transformers:
56
+ * - angular:
57
+ * html_files:
58
+ * - lib/_somelibrary/_some_component.html
59
+ *
60
+ * If you need a way to build your app without transformers, you can use
61
+ * [staticApplication] (#angular-app-static@id_staticApplication) directly, instead of
62
+ * [dynamicApplication] (#angular-app-dynamic@id_dynamicApplication). See the documentation for
63
+ * the [app:static] (#angular-app-static) library definition for more on this use case.
6
64
*/
7
65
library angular.app;
8
66
@@ -21,17 +79,15 @@ import 'package:angular/routing/module.dart';
21
79
import 'package:angular/introspection_js.dart' ;
22
80
23
81
/**
24
- * This is the top level module which describes the core angular of angular including filters and
25
- * directives. The module is automatically included with [Application]
82
+ * This is the top level module which describes all Angular components,
83
+ * including services, filters and directives. When writing an Angular application,
84
+ * AngularModule is automatically included.
26
85
*
27
- * The Module is made up of
86
+ * You can use AngularModule explicitly when creating a custom Injector that needs to know
87
+ * about Angular services, filters, and directives. When writing tests, this is typically done for
88
+ * you by the [SetUpInjector] (#angular-mock@id_setUpInjector) method.
28
89
*
29
- * - [NgCoreModule]
30
- * - [NgCoreDomModule]
31
- * - [NgDirectiveModule]
32
- * - [NgFilterModule]
33
- * - [NgPerfModule]
34
- * - [NgRoutingModule]
90
+
35
91
*/
36
92
class AngularModule extends Module {
37
93
AngularModule () {
@@ -48,27 +104,14 @@ class AngularModule extends Module {
48
104
}
49
105
50
106
/**
51
- * Application is how you configure and run an Angular application. Application is abstract. There are two
52
- * implementations: one is dynamic, using Mirrors; the other is static, using code generation.
53
- *
54
- * To create an Application, import angular_dynamic.dart and call dynamicApplication like so:
55
- *
56
- * import 'package:angular/angular.dart';
57
- * import 'package:angular/angular_dynamic.dart';
58
- *
59
- * class HelloWorldController {
60
- * ...
61
- * }
62
- *
63
- * main() {
64
- * dynamicApplication()
65
- * .addModule(new Module()..type(HelloWorldController))
66
- * .run();
67
- * }
68
- *
69
- * On `pub build` , dynamicApplication becomes staticApplication, as pub generates the getters,
70
- * setters, annotations, and factories for the root Injector that [ngApp] creates. This
107
+ * Application is how you configure and run an Angular application. There are two
108
+ * implementations for this abstract class:
71
109
*
110
+ * - [app:dynamic] (#angular-app-dynamic) for development, which uses transformers to generate the
111
+ * getters, setters, annotations, and factories needed by [dart:mirrors] (https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-mirrors) for tree shaking
112
+ * - [app:static] (#angular-app-static), for apps that explicitly specify their own getters,
113
+ * setters, annotations, and factories and do not rely on transformation or [dart:mirrors]
114
+ * (https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-mirrors)
72
115
*
73
116
*/
74
117
0 commit comments