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

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

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

Powered by Google App Engine
This is Rietveld 408576698