Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: third_party/pkg/angular/lib/bootstrap.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular; 1 part of angular;
2 2
3 /** 3 /**
4 * This is the top level module which describes the whole of angular. 4 * This is the top level module which describes the whole of angular.
5 * 5 *
6 * The Module is made up of 6 * The Module is made up of
7 * 7 *
8 * - [NgCoreModule] 8 * - [NgCoreModule]
9 * - [NgCoreDomModule] 9 * - [NgCoreDomModule]
10 * - [NgDirectiveModule] 10 * - [NgDirectiveModule]
11 * - [NgFilterModule] 11 * - [NgFilterModule]
12 * - [NgPerfModule] 12 * - [NgPerfModule]
13 * - [NgRoutingModule] 13 * - [NgRoutingModule]
14 */ 14 */
15 class AngularModule extends Module { 15 class AngularModule extends Module {
16 AngularModule() { 16 AngularModule() {
17 install(new NgCoreModule()); 17 install(new NgCoreModule());
18 install(new NgCoreDomModule()); 18 install(new NgCoreDomModule());
19 install(new NgDirectiveModule()); 19 install(new NgDirectiveModule());
20 install(new NgFilterModule()); 20 install(new NgFilterModule());
21 install(new NgPerfModule()); 21 install(new NgPerfModule());
22 install(new NgRoutingModule()); 22 install(new NgRoutingModule());
23 23
24 type(MetadataExtractor); 24 type(MetadataExtractor);
25 value(Expando, _elementExpando); 25 value(Expando, _elementExpando);
26 value(NgApp, new NgApp(dom.window.document.documentElement));
27 } 26 }
28 } 27 }
29 28
30 Injector _defaultInjectorFactory(List<Module> modules) => 29 Injector _defaultInjectorFactory(List<Module> modules) =>
31 new DynamicInjector(modules: modules); 30 new DynamicInjector(modules: modules);
32 31
33 /** 32 /**
34 * This method is the main entry point to an angular application. 33 * This method is the main entry point to an angular application.
35 * 34 *
36 * # The [ngBootstrap] is responsible for: 35 * # The [ngBootstrap] is responsible for:
37 * 36 *
38 * 1. Locating the root element of the application, 37 * 1. Locating the root element of the application,
39 * 2. Creating Angular [NgZone] 38 * 2. Creating Angular [NgZone]
40 * 3. Inside the [NgZone] create an injector 39 * 3. Inside the [NgZone] create an injector
41 * 4. Retrieve the [Compiler] and compile the root eleement 40 * 4. Retrieve the [Compiler] and compile the root eleement
42 * 41 *
43 * 42 *
44 * # Parameters: 43 * # Parameters:
45 * 44 *
46 * - [module] Option application module to add to the [Injector]. 45 * - [module] Option application module to add to the [Injector].
47 * - [modules] Optional list of [Module]s to add to the [Injector] (if more th an one is needed). 46 * - [modules] Optional list of [Module]s to add to the [Injector] (if more th an one is needed).
48 * - [element] Optional root element of the application. If non specified, the 47 * - [element] Optional root element of the application. If non specified, the
49 * the root element is looked up using the [selector]. If selector can not 48 * the root element is looked up using the [selector]. If selector can not
50 * identify a root, the root [HTML] element is used for bootstraping. 49 * identify a root, the root [HTTML] element is used for bootstraping.
51 * - [selector] Optional CSS selector used to locate the root element for the application. 50 * - [selector] Optional CSS selector used to locate the root element for the application.
52 * - [injectorFactor] Optional factory responsible for creating the injector. 51 * - [injectorFactor] Optional factory responsible for creating the injector.
53 * 52 *
54 * 53 *
55 * 54 *
56 * # A typical way to boostrap an Angular application: 55 * # A typical way to boostrap an Angular application:
57 * 56 *
58 * Module myAppModule = new Module(); 57 * Module myAppModule = new Module();
59 * myAppModule.type(MyType); 58 * myAppModule.type(MyType);
60 * .... 59 * ....
61 * Injector injector = ngBootstrap(module: myAppModule); 60 * Injector injector = ngBootstrap(module: myAppModule);
62 */ 61 */
63 Injector ngBootstrap({ 62 Injector ngBootstrap({
64 Module module: null, 63 Module module: null,
65 List<Module> modules: null, 64 List<Module> modules: null,
66 dom.Element element: null, 65 dom.Element element: null,
67 String selector: '[ng-app]', 66 String selector: '[ng-app]',
68 Injector injectorFactory(List<Module> modules): _defaultInjectorFactory}) { 67 Injector injectorFactory(List<Module> modules): _defaultInjectorFactory} ) {
69 _publishToJavaScript(); 68 _publishToJavaScript();
70 69
71 var ngModules = [new AngularModule()]; 70 var ngModules = [new AngularModule()];
72 if (module != null) ngModules.add(module); 71 if (module != null) ngModules.add(module);
73 if (modules != null) ngModules.addAll(modules); 72 if (modules != null) ngModules.addAll(modules);
74 if (element == null) { 73 if (element == null) {
75 element = dom.querySelector(selector); 74 element = dom.querySelector(selector);
76 var document = dom.window.document; 75 var document = dom.window.document;
77 if (element == null) { 76 if (element == null) element = document.childNodes.firstWhere((e) => e is do m.Element);
78 element = document.childNodes.firstWhere((e) => e is dom.Element);
79 }
80 } 77 }
81 78
82 // The injector must be created inside the zone, so we create the 79 // The injector must be created inside the zone, so we create the
83 // zone manually and give it back to the injector as a value. 80 // zone manually and give it back to the injector as a value.
84 NgZone zone = new NgZone(); 81 NgZone zone = new NgZone();
85 ngModules.add(new Module() 82 ngModules.add(new Module()..value(NgZone, zone));
86 ..value(NgZone, zone)
87 ..value(NgApp, new NgApp(element)));
88 83
89 return zone.run(() { 84 return zone.run(() {
90 var rootElements = [element]; 85 var rootElements = [element];
91 Injector injector = injectorFactory(ngModules); 86 Injector injector = injectorFactory(ngModules);
92 injector.get(Compiler)(rootElements, injector.get(DirectiveMap)) 87 injector.get(Compiler)(rootElements)(injector, rootElements);
93 (injector, rootElements);
94 return injector; 88 return injector;
95 }); 89 });
96 } 90 }
97
98 /// Holds a reference to the root of the application used by ngBootstrap.
99 class NgApp {
100 final dom.Element root;
101 NgApp(this.root);
102 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/angular.dart ('k') | third_party/pkg/angular/lib/change_detection/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698