From b11438f211ed7009335bc18f5cbf2950fc4014fa Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Fri, 11 Nov 2016 19:44:00 -0800 Subject: [PATCH] docs(ts-to-js): add separate template files for some components --- .../app/confirm.component.html | 6 + .../hero-di-inject-additional.component.es6 | 9 +- .../app/hero-io.component.es6 | 10 +- .../app/title.component.html | 3 + .../js-es6/app/confirm.component.html | 6 + .../hero-di-inject-additional.component.es6 | 9 +- .../js-es6/app/hero-io.component.es6 | 10 +- .../js-es6/app/title.component.html | 3 + .../cb-ts-to-js/js/app/confirm.component.html | 6 + .../hero-di-inject-additional.component.js | 10 +- .../cb-ts-to-js/js/app/hero-io.component.js | 10 +- .../cb-ts-to-js/js/app/title.component.html | 3 + .../docs/_examples/cb-ts-to-js/js/index.html | 1 - .../cb-ts-to-js/ts/app/confirm.component.html | 6 + .../hero-di-inject-additional.component.ts | 9 +- .../cb-ts-to-js/ts/app/hero-io.component.ts | 10 +- .../cb-ts-to-js/ts/app/title.component.html | 4 + public/docs/ts/latest/cookbook/ts-to-js.jade | 129 ++++++++++++------ 18 files changed, 148 insertions(+), 96 deletions(-) create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/confirm.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/confirm.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/title.component.html diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.html b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.html new file mode 100644 index 0000000000..917bd1696f --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.html @@ -0,0 +1,6 @@ + + diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject-additional.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject-additional.component.es6 index 8cd77b51f6..83e3dab59f 100644 --- a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject-additional.component.es6 +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject-additional.component.es6 @@ -8,14 +8,13 @@ import { import { BrowserModule } from '@angular/platform-browser'; // #docregion +// #docregion metadata @Component({ + moduleId: module.id, selector: 'hero-title', - template: ` -

{{titlePrefix}} {{title}}

- -

{{ msg }}

- ` + templateUrl: 'title.component.html' }) +// #enddocregion metadata class TitleComponent { msg = ''; constructor( diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6 index 2b954b138a..dddbb34733 100644 --- a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6 +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6 @@ -9,15 +9,9 @@ import { BrowserModule } from '@angular/platform-browser'; // #docregion @Component({ + moduleId: module.id, selector: 'my-confirm', - template: ` - - - ` + templateUrl: 'confirm.component.html' }) class ConfirmComponent { @Input() okMsg; diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/title.component.html b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/title.component.html new file mode 100644 index 0000000000..06d6f3db91 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/title.component.html @@ -0,0 +1,3 @@ +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.html b/public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.html new file mode 100644 index 0000000000..917bd1696f --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.html @@ -0,0 +1,6 @@ + + diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6 index 295d305ac4..398e38d352 100644 --- a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6 +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6 @@ -20,16 +20,15 @@ class TitleComponent { } } +// #docregion metadata TitleComponent.annotations = [ new Component({ + moduleId: module.id, selector: 'hero-title', - template: ` -

{{titlePrefix}} {{title}}

- -

{{ msg }}

- ` + templateUrl: 'title.component.html' }) ]; +// #enddocregion metadata TitleComponent.parameters = [ [new Optional(), new Inject('titlePrefix')], diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-io.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-io.component.es6 index 549d75ce7c..3ed92792db 100644 --- a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-io.component.es6 +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-io.component.es6 @@ -23,15 +23,9 @@ class ConfirmComponent { ConfirmComponent.annotations = [ new Component({ + moduleId: module.id, selector: 'my-confirm', - template: ` - - - `, + templateUrl: 'confirm.component.html', inputs: [ 'okMsg', 'notOkMsg: cancelMsg' diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/title.component.html b/public/docs/_examples/cb-ts-to-js/js-es6/app/title.component.html new file mode 100644 index 0000000000..06d6f3db91 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/title.component.html @@ -0,0 +1,3 @@ +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/js/app/confirm.component.html b/public/docs/_examples/cb-ts-to-js/js/app/confirm.component.html new file mode 100644 index 0000000000..917bd1696f --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/confirm.component.html @@ -0,0 +1,6 @@ + + diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject-additional.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject-additional.component.js index 64009317a9..127bf524a8 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject-additional.component.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject-additional.component.js @@ -1,13 +1,13 @@ (function(app) { // #docregion + // #docregion metadata var TitleComponent = ng.core.Component({ selector: 'hero-title', - template: - '

{{titlePrefix}} {{title}}

' + - '' + - '

{{ msg }}

' - }).Class({ + templateUrl: 'app/title.component.html' + }) + // #enddocregion metadata + .Class({ constructor: [ [ new ng.core.Optional(), new ng.core.Inject('titlePrefix') ], new ng.core.Attribute('title'), diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.js index 79aef12125..611d3b842b 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.js @@ -2,6 +2,7 @@ // #docregion var ConfirmComponent = ng.core.Component({ selector: 'my-confirm', + templateUrl: 'app/confirm.component.html', inputs: [ 'okMsg', 'notOkMsg: cancelMsg' @@ -9,14 +10,7 @@ outputs: [ 'ok', 'notOk: cancel' - ], - template: - '' + - '' + ] }).Class({ constructor: function() { this.ok = new ng.core.EventEmitter(); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/title.component.html b/public/docs/_examples/cb-ts-to-js/js/app/title.component.html new file mode 100644 index 0000000000..06d6f3db91 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/title.component.html @@ -0,0 +1,3 @@ +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/js/index.html b/public/docs/_examples/cb-ts-to-js/js/index.html index 448c295609..3c2dd6eeca 100644 --- a/public/docs/_examples/cb-ts-to-js/js/index.html +++ b/public/docs/_examples/cb-ts-to-js/js/index.html @@ -16,7 +16,6 @@ - diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/confirm.component.html b/public/docs/_examples/cb-ts-to-js/ts/app/confirm.component.html new file mode 100644 index 0000000000..917bd1696f --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/confirm.component.html @@ -0,0 +1,6 @@ + + diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject-additional.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject-additional.component.ts index d36b3eff19..37e00960c9 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject-additional.component.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject-additional.component.ts @@ -8,14 +8,13 @@ import { import { BrowserModule } from '@angular/platform-browser'; // #docregion +// #docregion metadata @Component({ + moduleId: module.id, selector: 'hero-title', - template: ` -

{{titlePrefix}} {{title}}

- -

{{ msg }}

- ` + templateUrl: 'title.component.html' }) +// #enddocregion metadata class TitleComponent { private msg: string = ''; constructor( diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-io.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-io.component.ts index 8cf430c000..8105d98919 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/hero-io.component.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-io.component.ts @@ -9,15 +9,9 @@ import { BrowserModule } from '@angular/platform-browser'; // #docregion @Component({ + moduleId: module.id, selector: 'my-confirm', - template: ` - - - ` + templateUrl: 'confirm.component.html' }) class ConfirmComponent { @Input() okMsg: string; diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/title.component.html b/public/docs/_examples/cb-ts-to-js/ts/app/title.component.html new file mode 100644 index 0000000000..0e93122d5c --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/title.component.html @@ -0,0 +1,4 @@ + +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/ts/latest/cookbook/ts-to-js.jade b/public/docs/ts/latest/cookbook/ts-to-js.jade index 966d1383fe..0c3ba61544 100644 --- a/public/docs/ts/latest/cookbook/ts-to-js.jade +++ b/public/docs/ts/latest/cookbook/ts-to-js.jade @@ -80,7 +80,7 @@ a#modularity In both _TypeScript_ and _ES6_, you import Angular classes, functions, and other members with _ES6_ `import` statements. - In _ES5_, you access the Angular entities of the [the Angular packages](../glossary.html#!#scoped-package), + In _ES5_, you access the Angular entities of the [the Angular packages](../glossary.html#!#scoped-package) through the global `ng` object. Everything you would have imported from `@angular` is a nested member of this `ng` object: @@ -102,23 +102,29 @@ a#modularity `) :marked - ### Importing and Exporting Application Code + ### Exporting Application Code Each file in a _TypeScript_ or _ES6_ Angular application constitutes an _ES6_ module. When you want to make something available to other modules, you `export` it. _ES5_ lacks native support for modules. - In an Angular _ES5_ application, you load each file manually by adding a `