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

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

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback 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));
26 } 27 }
27 } 28 }
28 29
29 Injector _defaultInjectorFactory(List<Module> modules) => 30 Injector _defaultInjectorFactory(List<Module> modules) =>
30 new DynamicInjector(modules: modules); 31 new DynamicInjector(modules: modules);
31 32
32 /** 33 /**
33 * This method is the main entry point to an angular application. 34 * This method is the main entry point to an angular application.
34 * 35 *
35 * # The [ngBootstrap] is responsible for: 36 * # The [ngBootstrap] is responsible for:
36 * 37 *
37 * 1. Locating the root element of the application, 38 * 1. Locating the root element of the application,
38 * 2. Creating Angular [NgZone] 39 * 2. Creating Angular [NgZone]
39 * 3. Inside the [NgZone] create an injector 40 * 3. Inside the [NgZone] create an injector
40 * 4. Retrieve the [Compiler] and compile the root eleement 41 * 4. Retrieve the [Compiler] and compile the root eleement
41 * 42 *
42 * 43 *
43 * # Parameters: 44 * # Parameters:
44 * 45 *
45 * - [module] Option application module to add to the [Injector]. 46 * - [module] Option application module to add to the [Injector].
46 * - [modules] Optional list of [Module]s to add to the [Injector] (if more th an one is needed). 47 * - [modules] Optional list of [Module]s to add to the [Injector] (if more th an one is needed).
47 * - [element] Optional root element of the application. If non specified, the 48 * - [element] Optional root element of the application. If non specified, the
48 * the root element is looked up using the [selector]. If selector can not 49 * the root element is looked up using the [selector]. If selector can not
49 * identify a root, the root [HTTML] element is used for bootstraping. 50 * identify a root, the root [HTML] element is used for bootstraping.
50 * - [selector] Optional CSS selector used to locate the root element for the application. 51 * - [selector] Optional CSS selector used to locate the root element for the application.
51 * - [injectorFactor] Optional factory responsible for creating the injector. 52 * - [injectorFactor] Optional factory responsible for creating the injector.
52 * 53 *
53 * 54 *
54 * 55 *
55 * # A typical way to boostrap an Angular application: 56 * # A typical way to boostrap an Angular application:
56 * 57 *
57 * Module myAppModule = new Module(); 58 * Module myAppModule = new Module();
58 * myAppModule.type(MyType); 59 * myAppModule.type(MyType);
59 * .... 60 * ....
60 * Injector injector = ngBootstrap(module: myAppModule); 61 * Injector injector = ngBootstrap(module: myAppModule);
61 */ 62 */
62 Injector ngBootstrap({ 63 Injector ngBootstrap({
63 Module module: null, 64 Module module: null,
64 List<Module> modules: null, 65 List<Module> modules: null,
65 dom.Element element: null, 66 dom.Element element: null,
66 String selector: '[ng-app]', 67 String selector: '[ng-app]',
67 Injector injectorFactory(List<Module> modules): _defaultInjectorFactory} ) { 68 Injector injectorFactory(List<Module> modules): _defaultInjectorFactory}) {
68 _publishToJavaScript(); 69 _publishToJavaScript();
69 70
70 var ngModules = [new AngularModule()]; 71 var ngModules = [new AngularModule()];
71 if (module != null) ngModules.add(module); 72 if (module != null) ngModules.add(module);
72 if (modules != null) ngModules.addAll(modules); 73 if (modules != null) ngModules.addAll(modules);
73 if (element == null) { 74 if (element == null) {
74 element = dom.querySelector(selector); 75 element = dom.querySelector(selector);
75 var document = dom.window.document; 76 var document = dom.window.document;
76 if (element == null) element = document.childNodes.firstWhere((e) => e is do m.Element); 77 if (element == null) {
78 element = document.childNodes.firstWhere((e) => e is dom.Element);
79 }
77 } 80 }
78 81
79 // The injector must be created inside the zone, so we create the 82 // The injector must be created inside the zone, so we create the
80 // zone manually and give it back to the injector as a value. 83 // zone manually and give it back to the injector as a value.
81 NgZone zone = new NgZone(); 84 NgZone zone = new NgZone();
82 ngModules.add(new Module()..value(NgZone, zone)); 85 ngModules.add(new Module()
86 ..value(NgZone, zone)
87 ..value(NgApp, new NgApp(element)));
83 88
84 return zone.run(() { 89 return zone.run(() {
85 var rootElements = [element]; 90 var rootElements = [element];
86 Injector injector = injectorFactory(ngModules); 91 Injector injector = injectorFactory(ngModules);
87 injector.get(Compiler)(rootElements)(injector, rootElements); 92 injector.get(Compiler)(rootElements, injector.get(DirectiveMap))
93 (injector, rootElements);
88 return injector; 94 return injector;
89 }); 95 });
90 } 96 }
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