| OLD | NEW |
| 1 part of angular.directive; | 1 part of angular.directive; |
| 2 | 2 |
| 3 /** | 3 /** |
| 4 * The [NgTemplateElementDirective] allows one to preload an Angular template | 4 * The [NgTemplate] allows one to preload an Angular template |
| 5 * into the [TemplateCache]. It works on `<template>` and `<script>` elements | 5 * into the [TemplateCache]. It works on `<template>` and `<script>` elements |
| 6 * that have `type="text/ng-template`. For such elements, The entire contents | 6 * that have `type="text/ng-template`. For such elements, The entire contents |
| 7 * of the elements are loaded into the [TemplateCache] under the URL specified | 7 * of the elements are loaded into the [TemplateCache] under the URL specified |
| 8 * by the `id` attribute. | 8 * by the `id` attribute. |
| 9 * | 9 * |
| 10 * Sample usage: | 10 * Sample usage: |
| 11 * | 11 * |
| 12 * <template id="template_1.html" type="text/ng-template"> | 12 * <template id="template_1.html" type="text/ng-template"> |
| 13 * TEMPLATE 1 CONTENTS | 13 * TEMPLATE 1 CONTENTS |
| 14 * </template> | 14 * </template> |
| 15 * <script id="template_2.html" type="text/ng-template"> | 15 * <script id="template_2.html" type="text/ng-template"> |
| 16 * TEMPLATE 2 CONTENTS | 16 * TEMPLATE 2 CONTENTS |
| 17 * </template> | 17 * </template> |
| 18 * | 18 * |
| 19 * Refer [TemplateCache] for a **full example** as well as more information. | 19 * Refer [TemplateCache] for a **full example** as well as more information. |
| 20 */ | 20 */ |
| 21 @NgDirective( | 21 @Decorator( |
| 22 selector: 'template[type=text/ng-template]', | 22 selector: 'template[type=text/ng-template]', |
| 23 map: const {'id': '@templateUrl'}) | 23 map: const {'id': '@templateUrl'}) |
| 24 @NgDirective( | 24 @Decorator( |
| 25 selector: 'script[type=text/ng-template]', | 25 selector: 'script[type=text/ng-template]', |
| 26 children: NgAnnotation.IGNORE_CHILDREN, | 26 children: Directive.IGNORE_CHILDREN, |
| 27 map: const {'id': '@templateUrl'}) | 27 map: const {'id': '@templateUrl'}) |
| 28 class NgTemplateDirective { | 28 class NgTemplate { |
| 29 final dom.Element element; | 29 final dom.Element element; |
| 30 final TemplateCache templateCache; | 30 final TemplateCache templateCache; |
| 31 | 31 |
| 32 NgTemplateDirective(this.element, this.templateCache); | 32 NgTemplate(this.element, this.templateCache); |
| 33 set templateUrl(url) => templateCache.put(url, new HttpResponse(200, | 33 set templateUrl(url) => templateCache.put(url, new HttpResponse(200, |
| 34 element is dom.TemplateElement | 34 element is dom.TemplateElement |
| 35 ? (element as dom.TemplateElement).content.innerHtml | 35 ? (element as dom.TemplateElement).content.innerHtml |
| 36 : element.innerHtml)); | 36 : element.innerHtml)); |
| 37 } | 37 } |
| 38 |
| 39 |
| OLD | NEW |