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

Side by Side Diff: third_party/pkg/angular/lib/directive/ng_include.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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.directive; 1 part of angular.directive;
2 2
3 /** 3 /**
4 * Fetches, compiles and includes an external Angular template/HTML. 4 * Fetches, compiles and includes an external Angular template/HTML.
5 * 5 *
6 * A new child [Scope] is created for the included DOM subtree. 6 * A new child [Scope] is created for the included DOM subtree.
7 * 7 *
8 * [NgIncludeDirective] provides only one small part of the power of 8 * [NgIncludeDirective] provides only one small part of the power of
9 * [NgComponent].  Consider using directives and components instead as they 9 * [NgComponent].  Consider using directives and components instead as they
10 * provide this feature as well as much more. 10 * provide this feature as well as much more.
11 * 11 *
12 * Note: The browser's Same Origin Policy (<http://v.gd/5LE5CA>) and 12 * Note: The browser's Same Origin Policy (<http://v.gd/5LE5CA>) and
13 * Cross-Origin Resource Sharing (CORS) policy (<http://v.gd/nXoY8y>) restrict 13 * Cross-Origin Resource Sharing (CORS) policy (<http://v.gd/nXoY8y>) restrict
14 * whether the template is successfully loaded.  For example, 14 * whether the template is successfully loaded.  For example,
15 * [NgIncludeDirective] won't work for cross-domain requests on all browsers and 15 * [NgIncludeDirective] won't work for cross-domain requests on all browsers and
16 * for `file://` access on some browsers. 16 * for `file://` access on some browsers.
17 */ 17 */
18 @NgDirective( 18 @NgDirective(
19 selector: '[ng-include]', 19 selector: '[ng-include]',
20 map: const {'ng-include': '@url'} ) 20 map: const {'ng-include': '@url'})
21 class NgIncludeDirective { 21 class NgIncludeDirective {
22 22
23 dom.Element element; 23 final dom.Element element;
24 Scope scope; 24 final Scope scope;
25 BlockCache blockCache; 25 final BlockCache blockCache;
26 Injector injector; 26 final Injector injector;
27 final DirectiveMap directives;
27 28
28 Block _previousBlock; 29 Block _previousBlock;
29 Scope _previousScope; 30 Scope _previousScope;
30 31
31 NgIncludeDirective(this.element, this.scope, this.blockCache, this.injector); 32 NgIncludeDirective(this.element, this.scope, this.blockCache, this.injector, t his.directives);
32 33
33 _cleanUp() { 34 _cleanUp() {
34 if (_previousBlock == null) { 35 if (_previousBlock == null) return;
35 return;
36 }
37 36
38 _previousBlock.remove(); 37 _previousBlock.remove();
39 _previousScope.$destroy(); 38 _previousScope.destroy();
40 element.innerHtml = ''; 39 element.innerHtml = '';
41 40
42 _previousBlock = null; 41 _previousBlock = null;
43 _previousScope = null; 42 _previousScope = null;
44 } 43 }
45 44
46 _updateContent(createBlock) { 45 _updateContent(createBlock) {
47 // create a new scope 46 // create a new scope
48 _previousScope = scope.$new(); 47 _previousScope = scope.createChild(new PrototypeMap(scope.context));
49 _previousBlock = createBlock(injector.createChild([new Module()..value(Scope , _previousScope)])); 48 _previousBlock = createBlock(injector.createChild([new Module()
49 ..value(Scope, _previousScope)]));
50 50
51 _previousBlock.elements.forEach((elm) => element.append(elm)); 51 _previousBlock.elements.forEach((elm) => element.append(elm));
52 } 52 }
53 53
54 54
55 set url(value) { 55 set url(value) {
56 _cleanUp(); 56 _cleanUp();
57 if (value != null && value != '') { 57 if (value != null && value != '') {
58 blockCache.fromUrl(value).then(_updateContent); 58 blockCache.fromUrl(value, directives).then(_updateContent);
59 } 59 }
60 } 60 }
61 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698