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

Unified Diff: third_party/pkg/angular/lib/directive/ng_template.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, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/directive/ng_template.dart
diff --git a/third_party/pkg/angular/lib/directive/ng_template.dart b/third_party/pkg/angular/lib/directive/ng_template.dart
new file mode 100644
index 0000000000000000000000000000000000000000..07e6a499f6ce722c718fe94f10827c5219573a1c
--- /dev/null
+++ b/third_party/pkg/angular/lib/directive/ng_template.dart
@@ -0,0 +1,37 @@
+part of angular.directive;
+
+/**
+ * The [NgTemplateElementDirective] allows one to preload an Angular template
+ * into the [TemplateCache]. It works on `<template>` and `<script>` elements
+ * that have `type="text/ng-template`. For such elements, The entire contents
+ * of the elements are loaded into the [TemplateCache] under the URL specified
+ * by the `id` attribute.
+ *
+ * Sample usage:
+ *
+ * <template id="template_1.html" type="text/ng-template">
+ * TEMPLATE 1 CONTENTS
+ * </template>
+ * <script id="template_2.html" type="text/ng-template">
+ * TEMPLATE 2 CONTENTS
+ * </template>
+ *
+ * Refer [TemplateCache] for a **full example** as well as more information.
+ */
+@NgDirective(
+ selector: 'template[type=text/ng-template]',
+ map: const {'id': '@templateUrl'})
+@NgDirective(
+ selector: 'script[type=text/ng-template]',
+ children: NgAnnotation.IGNORE_CHILDREN,
+ map: const {'id': '@templateUrl'})
+class NgTemplateDirective {
+ dom.Element element;
+ TemplateCache templateCache;
+
+ NgTemplateDirective(this.element, this.templateCache);
+ set templateUrl(url) => templateCache.put(url, new HttpResponse(200,
+ (element is dom.TemplateElement
+ ? (element as dom.TemplateElement).content.innerHtml
+ : element.innerHtml)));
+}

Powered by Google App Engine
This is Rietveld 408576698