From eb60bfe20e2c6eda6d247e1f0393932088de93e1 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 15 Nov 2016 00:44:35 +0000 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 17c7e154672dbf5feeeb971ed3b594d318703748 Author: Filipe Silva Date: Mon Nov 14 23:11:37 2016 +0000 chore: update to 2.2.0 (#2797) commit 1e5facfb980b85313d51559b3272950f662ce20c Merge: 5c4cc9a db0fac9 Author: Ward Bell Date: Mon Nov 14 12:44:51 2016 -0800 Merge pull request #2799 from IdeaBlade/docs-changelog-2.2.0 chore(changelog): update docs changelog for Ng v.2.2.0 commit 5c4cc9a3c8b2718b71ab7c3d1b5dd02bfdd5f1fc Merge: 43457e9 1afe5dc Author: Ward Bell Date: Mon Nov 14 12:43:09 2016 -0800 docs(router): Updated usage of observables in router tutorial and developer guide (#2696) Moved route configuration into separate variable for consistency Added async pipe to handle subscriptions for list items commit 43457e9765c63b3889ab449959fe295327390315 Merge: a423a5a 2649647 Author: Jesús Rodríguez Date: Mon Nov 14 21:38:49 2016 +0100 chore: add upgrade/static to API reference (#2755) commit 1afe5dc97d457e045adb6c0e03d27023aa97eea5 Author: Brandon Roberts Date: Sat Oct 29 16:08:54 2016 -0500 docs(router): Updated usage of observables in router tutorial and developer guide Moved route configuration into separate variable for consistency Added async pipe to handle subscriptions for list items commit db0fac94c980c99d9575a90d4b6bb15f572f9161 Author: Ward Bell Date: Mon Nov 14 10:48:09 2016 -0800 chore(changelog): update docs changelog for Ng v.2.2.0 commit a423a5abc704280794b6dea69cf1c9e76bbc9da1 Author: ikilled Date: Mon Nov 14 18:39:46 2016 +0000 clicking on Books & Training sends user to Education (#2701) When user clicks in Books & Training item in footer the website should take them to Education section (anchor) in the middle of the page, not to the top where Development section is. commit d63b1ccea36f4cf52333c846184b8e6876284a0a Merge: f627706 8508140 Author: Ward Bell Date: Mon Nov 14 10:35:48 2016 -0800 docs(router): fixed verbiage about router-outlet (#2746) commit f627706779c418ca8357aacd52aba5b5b7d05cb0 Author: Ward Bell Date: Mon Nov 14 10:26:13 2016 -0800 docs(cookbook-aot-compiler): improve Ahead-of-Time compilation cookbook (#2798) closes #2790 commit 75464d585cac944e3cffb4401663e4c1185b7cb5 Merge: 78e2584 02f5559 Author: Ward Bell Date: Mon Nov 14 09:34:36 2016 -0800 Merge pull request #2794 from IdeaBlade/chalin-guide-misc-fix-1113 docs: guide/index misc Jade fixes commit 78e25840b229b0fe345feacf786f34e62b2cb963 Merge: 182493f 85062c4 Author: Ward Bell Date: Mon Nov 14 09:33:55 2016 -0800 Merge pull request #2795 from IdeaBlade/chalin-util-js-getExampleName-1114 chore(util.js): getExampleName - support optional .html suffix commit 182493f8779fa37422dd942813fc5681dbdac55f Merge: 9e9666b 53f5538 Author: Ward Bell Date: Mon Nov 14 09:28:40 2016 -0800 feat(cb-ts-to-js): add es6 examples (#2606) * feat(cb-ts-to-js): add es6 examples update docshredder to shred .es6 optimized focus gulp task convert imports and metadate sections add DI section add host and query metadata section add intro fix capitalization and grammar * docs(ts-to-js): ward's edits (incomplete) * docs(ts-to-js): add separate template files for some components * docs(cb-ts-to-js): refactor sample code commit 53f5538859c4d243552d288872e8c8fc8156f446 Author: Ward Bell Date: Sun Nov 13 14:09:28 2016 -0800 docs(cb-ts-to-js): refactor sample code commit 9e9666b2cc3ce57cac172894e935f0c6b9f7d6f4 Author: Patrice Chalin Date: Mon Nov 14 08:34:10 2016 -0800 docs(template-syntax/dart): updates to match TS (#2751) * docs(template-syntax): refresh _cache * docs(template-syntax/dart): updates to match TS - Propagates TS-side changes: - update #2639 - new two-way binding section, and - fix #2687 - invalid attr syntax - Fixes - #1898 - currency symbols - #2748 - Dart template-syntax e2e is failing - #2749 - deprecated `[className]` * updated _cache file following Kathy's post-review edits * Post Ward's review w/ cache updated - Keep `my-` and `my` prefixes on selectors (for components and directives, respectively). - Drop `my-` from file names. - Drop `My` as component class prefix. commit 5dcffd69dc09b48d99af4acd0dd06b029416e103 Author: Patrice Chalin Date: Sun Nov 13 19:37:13 2016 -0800 docs: dart glossary - fix misnamed Jade block commit 6680acc513a0178bb522f5bc99d66f366542d33c Merge: 14db838 3b03573 Author: Kathy Walrath Date: Mon Nov 14 08:31:11 2016 -0800 docs(toh): avoid dup header title (#2796) * remove redundant headings * update _cache * misc: make block comment a Jade comment (This prevents the text from appearing in the generated HTML as an HTML comment.) commit 3b03573f340cc7fc43e2642bdf52fb1bae61aff0 Author: Patrice Chalin Date: Mon Nov 14 05:30:05 2016 -0800 misc: make block comment a Jade comment (This prevents the text from appearing in the generated HTML as an HTML comment.) commit 470426d5e03829442449cb59c0528811c6011c37 Author: Patrice Chalin Date: Mon Nov 14 05:25:36 2016 -0800 update _cache commit c12d75a477a1e33ea37886c0bd5942ddb9c955b3 Author: Patrice Chalin Date: Mon Nov 14 05:23:35 2016 -0800 remove redundant headings commit 85062c47cac44d63b06b97ae86b2a4f596889ad6 Author: Patrice Chalin Date: Mon Nov 14 04:56:12 2016 -0800 chore(util.js): getExampleName - support optional .html suffix commit 02f55592b232618407a3a8fce70845589ee78978 Author: Patrice Chalin Date: Mon Nov 14 04:29:17 2016 -0800 docs: guide/index misc Jade fixes - Eliminate use of deprecated `clear=“all”` in `
`. - No need for local `langName`; use global `_Lang` var instead. - Remove duplicate id `learning-path`. commit 14db838f8b76309597140d9857acb92c76c864f6 Author: Naomi Black Date: Sun Nov 13 21:48:52 2016 -0500 news(nov): Some news and a blog post update commit eff32ecbdd5a52d2240afd5ad4e14bdab21c9a8f Author: Naomi Black Date: Sun Nov 13 21:48:37 2016 -0500 chore(bios): update some bios for leads commit 3ee36fbba211d115414d322b17a67626ed90d450 Author: koyner Date: Sun Nov 13 22:59:59 2016 +0100 docs(forms): grammar fix (#2764) commit b11438f211ed7009335bc18f5cbf2950fc4014fa Author: Ward Bell Date: Fri Nov 11 19:44:00 2016 -0800 docs(ts-to-js): add separate template files for some components commit 33b61977b2cd0bc35b257ce526d5dd2fd460cd10 Author: Ward Bell Date: Thu Nov 3 01:37:55 2016 -0700 docs(ts-to-js): ward's edits (incomplete) commit 12eb19fa3c34bb48b28da8bd33d94d7cc0526cf5 Author: Filipe Silva Date: Thu Oct 13 17:59:00 2016 +0100 feat(cb-ts-to-js): add es6 examples update docshredder to shred .es6 optimized focus gulp task convert imports and metadate sections add DI section add host and query metadata section add intro fix capitalization and grammar commit 64a8754386c0aa727e61d140d86bd31b6891ea99 Author: Patrice Chalin Date: Thu Nov 10 20:01:36 2016 -0800 example(template-syntax): follow style-guide and other updates (#2750) commit 7619cdf4a4ac592d74c25a372234c2d3964355dc Author: Jesús Rodríguez Date: Thu Nov 10 23:47:30 2016 +0100 chore: ability to open a plunker on a specific file (#2778) commit 0161d9db39b08be6a29e5a00b362c1eff12bf6b9 Author: Filipe Silva Date: Thu Nov 10 22:45:22 2016 +0000 chore: ignore debug.log file (#2785) This file is generated when running `gulp e2e` and often enough committed by mistake. /cc @foxandxss commit f92983cc6f7a895b751a6023791a283bb2e41073 Author: Jesús Rodríguez Date: Thu Nov 10 23:44:51 2016 +0100 docs(ngmodule): fix plunkers (#2786) commit 03db4bbc4873d8b68d08ef32bfa1b2b43cf46224 Author: Martin Eckardt Date: Wed Nov 9 17:43:40 2016 +0100 docs(a1-a2): fix link to Filter/Pipes (#2770) commit 60565a5cf1dfa7e43cb18b448c7d61c5f765f0de Author: Pavol Pitonak Date: Wed Nov 9 17:42:57 2016 +0100 docs(testing): configureTestModule -> configureTestingModule (#2767) commit ec471974a776dc208b2c56115cf1105fa39c8f88 Author: Catalin Zalog Date: Wed Nov 9 18:41:56 2016 +0200 docs(style-guide): fix missing *.ts (#2763) commit 234e468d5d6a11782e306901f80546d8989f17b3 Author: Patrice Chalin Date: Tue Nov 8 08:21:02 2016 -0800 docs: intra-site links should be relative Contributes to #2772. commit 6b37da78e4901a57b6ebf77720ec4796f2bb5f5f Author: Patrice Chalin Date: Tue Nov 8 09:27:10 2016 -0800 docs(forms/dart): remove mention of FORM_DIRECTIVES Fixes #2752 commit c24dd074a6acbceb87f8e973969c9bd94f769d8f Author: Patrice Chalin Date: Tue Nov 8 14:48:03 2016 -0800 docs(toh-5/dart): use routerLink in dashboard (#2744) * docs(toh-5/dart): use routerLink in dashboard * minor edits to TS jade * remove dart/toh-pt5 from bad-code-excerpt-skip-patterns commit 2808878c36d7429611e4f0584323e99c9b83219e Author: Patrice Chalin Date: Tue Nov 8 07:41:27 2016 -0800 chore(deploy): don't name project in firebase deploy Naming the project would sometimes cause gulp to report `An unexpected error has occurred` with exit code 2. commit 2649647ecb14a28932405d6b0bc22afd1f931089 Author: Jesus Rodriguez Date: Sat Nov 5 00:37:47 2016 +0100 chore: add upgrade/static to API reference commit 850814097f9908781ce954d13878d20eed779c87 Merge: 37f93bc b1c2c27 Author: Adrian Irwin Date: Thu Nov 3 17:27:43 2016 -0700 Merge branch 'router' of https://github.com/adrianirwin/angular.io into router commit 37f93bc0cbc2a766846b7715b1d8ddeeec43de39 Author: Adrian Irwin Date: Thu Nov 3 17:25:55 2016 -0700 docs(router): fixed verbiage and example of how routed views are related to the router outlet commit b1c2c27d365186d4231a470945a0975482df58e9 Author: Adrian Irwin Date: Thu Nov 3 16:57:56 2016 -0700 docs(router): fixed verbiage and example of how routed views are related to the router outlet --- .gitignore | 1 + .travis.yml | 2 +- gulpfile.js | 13 +- harp.json | 6 +- public/_includes/_footer.jade | 2 +- public/docs/_examples/.gitignore | 1 + .../docs/_examples/_boilerplate/package.json | 1 + public/docs/_examples/cb-ts-to-js/e2e-spec.ts | 18 +- .../cb-ts-to-js/js-es6-decorators/.babelrc | 6 + .../js-es6-decorators/app/app.component.es6 | 15 + .../js-es6-decorators/app/app.component.html | 31 + .../js-es6-decorators/app/app.module.es6 | 55 ++ .../app/confirm.component.es6 | 22 + .../app/confirm.component.html | 6 + .../js-es6-decorators/app/data.service.es6 | 10 + .../hero-di-inject-additional.component.es6 | 7 + .../app/hero-di-inject.component.es6 | 13 + .../app/hero-di.component.es6 | 15 + .../app/hero-host-meta.component.es6 | 44 ++ .../app/hero-host.component.es6 | 39 + .../app/hero-io.component.es6 | 26 + .../app/hero-lifecycle.component.es6 | 14 + .../app/hero-queries.component.es6 | 81 +++ .../app/hero-title.component.es6 | 26 + .../app/hero-title.component.html | 4 + .../js-es6-decorators/app/hero.component.es6 | 14 + .../js-es6-decorators/app/main.es6 | 4 + .../js-es6-decorators/example-config.json | 4 + .../cb-ts-to-js/js-es6-decorators/index.html | 27 + .../cb-ts-to-js/js-es6-decorators/plnkr.json | 8 + .../_examples/cb-ts-to-js/js-es6/.babelrc | 5 + .../cb-ts-to-js/js-es6/app/app.component.es6 | 20 + .../cb-ts-to-js/js-es6/app/app.component.html | 30 + .../cb-ts-to-js/js-es6/app/app.module.es6 | 56 ++ .../js-es6/app/confirm.component.es6 | 32 + .../js-es6/app/confirm.component.html | 6 + .../cb-ts-to-js/js-es6/app/data.service.es6 | 13 + .../hero-di-inject-additional.component.es6 | 10 + .../js-es6/app/hero-di-inject.component.es6 | 20 + .../js-es6/app/hero-di.component.es6 | 22 + .../js-es6/app/hero-host.component.es6 | 50 ++ .../js-es6/app/hero-io.component.es6 | 31 + .../js-es6/app/hero-lifecycle.component.es6 | 15 + .../js-es6/app/hero-queries.component.es6 | 97 +++ .../js-es6/app/hero-title.component.es6 | 29 + .../js-es6/app/hero-title.component.html | 4 + .../cb-ts-to-js/js-es6/app/hero.component.es6 | 20 + .../_examples/cb-ts-to-js/js-es6/app/main.es6 | 4 + .../cb-ts-to-js/js-es6/example-config.json | 4 + .../_examples/cb-ts-to-js/js-es6/index.html | 27 + .../_examples/cb-ts-to-js/js-es6/plnkr.json | 8 + .../cb-ts-to-js/js/app/app.component.html | 47 ++ .../cb-ts-to-js/js/app/app.component.js | 20 + .../cb-ts-to-js/js/app/app.module.js | 46 ++ .../cb-ts-to-js/js/app/confirm.component.html | 6 + .../cb-ts-to-js/js/app/confirm.component.js | 73 ++ .../cb-ts-to-js/js/app/data.service.js | 9 +- .../hero-di-inject-additional.component.js | 64 +- .../js/app/hero-di-inject.component.js | 82 +-- .../js/app/hero-di-inline.component.js | 27 - .../cb-ts-to-js/js/app/hero-di.component.js | 50 +- .../cb-ts-to-js/js/app/hero-dsl.component.js | 31 - .../cb-ts-to-js/js/app/hero-host.component.js | 97 +++ .../js/app/hero-io-dsl.component.html | 7 + .../cb-ts-to-js/js/app/hero-io.component.html | 7 + .../cb-ts-to-js/js/app/hero-io.component.js | 100 +-- .../js/app/hero-lifecycle.component.js | 61 +- .../js/app/hero-queries.component.js | 92 +++ .../js/app/hero-title.component.html | 4 + .../js/app/hero-title.component.js | 60 ++ .../cb-ts-to-js/js/app/hero.component.js | 76 +- .../js/app/heroes-bindings.component.js | 39 - .../js/app/heroes-queries.component.js | 82 --- .../docs/_examples/cb-ts-to-js/js/app/main.js | 34 +- .../docs/_examples/cb-ts-to-js/js/index.html | 47 +- .../cb-ts-to-js/ts/app/app.component.html | 31 + .../cb-ts-to-js/ts/app/app.component.ts | 15 + .../cb-ts-to-js/ts/app/app.module.ts | 56 ++ .../cb-ts-to-js/ts/app/confirm.component.html | 6 + .../cb-ts-to-js/ts/app/confirm.component.ts | 22 + .../cb-ts-to-js/ts/app/data.service.ts | 4 +- .../hero-di-inject-additional.component.ts | 49 +- .../ts/app/hero-di-inject.component.ts | 18 +- .../cb-ts-to-js/ts/app/hero-di.component.ts | 16 +- .../ts/app/hero-host-meta.component.ts | 44 ++ .../cb-ts-to-js/ts/app/hero-host.component.ts | 39 + .../cb-ts-to-js/ts/app/hero-io.component.ts | 67 +- .../ts/app/hero-lifecycle.component.ts | 20 +- .../ts/app/hero-queries.component.ts | 83 +++ .../ts/app/hero-title.component.html | 4 + .../ts/app/hero-title.component.ts | 22 + .../cb-ts-to-js/ts/app/hero.component.ts | 22 +- .../ts/app/heroes-bindings.component.ts | 41 -- .../ts/app/heroes-queries.component.ts | 88 --- .../docs/_examples/cb-ts-to-js/ts/app/main.ts | 34 +- .../docs/_examples/cb-ts-to-js/ts/index.html | 28 +- .../docs/_examples/ngmodule/ts/index.0.html | 2 +- .../docs/_examples/ngmodule/ts/index.1.html | 2 +- .../docs/_examples/ngmodule/ts/index.1b.html | 2 +- .../docs/_examples/ngmodule/ts/index.2.html | 2 +- .../docs/_examples/ngmodule/ts/index.3.html | 2 +- public/docs/_examples/package.json | 6 +- .../_examples/quickstart/js/package.1.json | 20 +- .../_examples/quickstart/ts/package.1.json | 20 +- .../ts/app/admin/admin-routing.module.1.ts | 34 +- .../ts/app/admin/admin-routing.module.2.ts | 46 +- .../ts/app/admin/admin-routing.module.3.ts | 38 +- .../ts/app/admin/admin-routing.module.ts | 36 +- .../router/ts/app/app-routing.module.1.ts | 14 +- .../router/ts/app/app-routing.module.2.ts | 12 +- .../router/ts/app/app-routing.module.3.ts | 10 +- .../router/ts/app/app-routing.module.4.ts | 12 +- .../router/ts/app/app-routing.module.5.ts | 23 +- .../router/ts/app/app-routing.module.6.ts | 43 +- .../router/ts/app/app-routing.module.ts | 52 +- .../_examples/router/ts/app/app.module.0.ts | 44 +- .../_examples/router/ts/app/app.module.1.ts | 22 +- .../_examples/router/ts/app/app.routing.1.ts | 44 -- .../_examples/router/ts/app/app.routing.2.ts | 22 - .../_examples/router/ts/app/app.routing.3.ts | 16 - .../_examples/router/ts/app/app.routing.4.ts | 13 - .../_examples/router/ts/app/app.routing.5.ts | 16 - .../_examples/router/ts/app/app.routing.6.ts | 21 - .../crisis-center-routing.module.1.ts | 40 +- .../crisis-center-routing.module.2.ts | 78 +- .../crisis-center-routing.module.3.ts | 50 +- .../crisis-center-routing.module.4.ts | 60 +- .../crisis-center-routing.module.ts | 46 +- .../crisis-detail-resolve.service.ts | 2 +- .../crisis-detail.component.1.ts | 27 +- .../crisis-center/crisis-detail.component.ts | 15 +- .../crisis-center/crisis-list.component.1.ts | 32 +- .../crisis-center/crisis-list.component.ts | 23 +- .../ts/app/heroes/hero-detail.component.1.ts | 19 +- .../ts/app/heroes/hero-detail.component.2.ts | 15 +- .../ts/app/heroes/hero-detail.component.ts | 18 +- .../ts/app/heroes/hero-list.component.1.ts | 11 +- .../ts/app/heroes/hero-list.component.ts | 20 +- .../ts/app/heroes/heroes-routing.module.ts | 18 +- .../router/ts/app/login-routing.module.ts | 18 +- .../dart/lib/app_component.dart | 7 +- .../dart/lib/app_component.html | 31 +- ...ck_directive.dart => click_directive.dart} | 12 +- .../dart/lib/sizer_component.dart | 30 + .../_examples/template-syntax/e2e-spec.ts | 17 +- .../template-syntax/ts/app/app.component.html | 27 +- .../template-syntax/ts/app/app.component.ts | 17 +- .../template-syntax/ts/app/app.module.ts | 6 +- ...-click.directive.ts => click.directive.ts} | 16 +- .../template-syntax/ts/app/sizer.component.ts | 5 +- .../toh-5/dart/lib/dashboard_component.dart | 12 +- .../toh-5/dart/lib/dashboard_component.html | 2 +- ...nent.1.html => dashboard_component_1.html} | 0 .../toh-5/dart/lib/hero_detail_component.dart | 11 +- .../toh-5/dart/lib/heroes_component.dart | 2 + .../toh-5/ts/app/dashboard.component.1.ts | 1 - .../toh-5/ts/app/dashboard.component.ts | 1 - .../toh-5/ts/app/hero-detail.component.html | 2 +- .../toh-5/ts/app/hero-detail.component.ts | 12 +- .../toh-6/ts/app/hero-detail.component.ts | 9 +- public/docs/_examples/toh-6/ts/app/main.ts | 2 +- .../_examples/webpack/ts/package.webpack.json | 16 +- public/docs/dart/latest/cookbook/_data.json | 2 +- public/docs/dart/latest/guide/forms.jade | 6 - public/docs/dart/latest/guide/glossary.jade | 2 +- .../dart/latest/guide/template-syntax.jade | 10 - public/docs/dart/latest/tutorial/toh-pt1.jade | 2 - public/docs/dart/latest/tutorial/toh-pt2.jade | 1 - public/docs/dart/latest/tutorial/toh-pt4.jade | 1 - public/docs/dart/latest/tutorial/toh-pt5.jade | 11 +- public/docs/js/latest/_data.json | 2 +- public/docs/js/latest/cookbook/_data.json | 2 +- public/docs/js/latest/cookbook/ts-to-js.jade | 470 +----------- .../ts/_cache/guide/dependency-injection.jade | 10 +- .../docs/ts/_cache/guide/template-syntax.jade | 199 ++++-- public/docs/ts/_cache/tutorial/toh-pt5.jade | 226 +++--- public/docs/ts/_cache/tutorial/toh-pt6.jade | 21 +- public/docs/ts/latest/_data.json | 2 +- public/docs/ts/latest/cookbook/_data.json | 2 +- .../cookbook/a1-a2-quick-reference.jade | 2 +- .../docs/ts/latest/cookbook/aot-compiler.jade | 51 +- public/docs/ts/latest/cookbook/ts-to-js.jade | 670 +++++++++++++++++- public/docs/ts/latest/guide/change-log.jade | 14 + .../ts/latest/guide/dependency-injection.jade | 2 +- public/docs/ts/latest/guide/forms.jade | 2 +- public/docs/ts/latest/guide/index.jade | 10 +- public/docs/ts/latest/guide/npm-packages.jade | 2 +- public/docs/ts/latest/guide/router.jade | 52 +- public/docs/ts/latest/guide/style-guide.jade | 4 +- .../docs/ts/latest/guide/template-syntax.jade | 59 +- public/docs/ts/latest/guide/testing.jade | 6 +- public/docs/ts/latest/tutorial/_data.json | 1 + public/docs/ts/latest/tutorial/index.jade | 4 +- public/docs/ts/latest/tutorial/toh-pt1.jade | 2 - public/docs/ts/latest/tutorial/toh-pt2.jade | 1 - public/docs/ts/latest/tutorial/toh-pt4.jade | 1 - public/docs/ts/latest/tutorial/toh-pt5.jade | 131 ++-- public/docs/ts/latest/tutorial/toh-pt6.jade | 2 - public/events.jade | 11 - public/news.jade | 50 +- public/resources/js/util.js | 2 +- .../config/bad-code-excerpt-skip-patterns.txt | 1 - tools/api-builder/angular.io-package/index.js | 1 + tools/doc-shredder/doc-shredder.js | 2 +- tools/doc-shredder/regionExtractor.js | 1 + tools/plunker-builder/builder.js | 20 +- tools/plunker-builder/indexHtmlTranslator.js | 2 +- 207 files changed, 3903 insertions(+), 2364 deletions(-) create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/.babelrc create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.module.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.es6 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/data.service.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject-additional.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host-meta.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-lifecycle.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-queries.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/main.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/example-config.json create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/index.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6-decorators/plnkr.json create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/.babelrc create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/app.module.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.es6 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/data.service.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-host.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-io.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-lifecycle.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-queries.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/hero.component.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/app/main.es6 create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/example-config.json create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/index.html create mode 100644 public/docs/_examples/cb-ts-to-js/js-es6/plnkr.json create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/app.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/app.component.js create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/app.module.js 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/confirm.component.js delete mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-di-inline.component.js delete mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-dsl.component.js create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-host.component.js create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-io-dsl.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-queries.component.js create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.js delete mode 100644 public/docs/_examples/cb-ts-to-js/js/app/heroes-bindings.component.js delete mode 100644 public/docs/_examples/cb-ts-to-js/js/app/heroes-queries.component.js create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/app.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/app.component.ts create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/app.module.ts 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/confirm.component.ts create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/hero-host-meta.component.ts create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/hero-host.component.ts create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/hero-queries.component.ts create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.html create mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.ts delete mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/heroes-bindings.component.ts delete mode 100644 public/docs/_examples/cb-ts-to-js/ts/app/heroes-queries.component.ts delete mode 100644 public/docs/_examples/router/ts/app/app.routing.1.ts delete mode 100644 public/docs/_examples/router/ts/app/app.routing.2.ts delete mode 100644 public/docs/_examples/router/ts/app/app.routing.3.ts delete mode 100644 public/docs/_examples/router/ts/app/app.routing.4.ts delete mode 100644 public/docs/_examples/router/ts/app/app.routing.5.ts delete mode 100644 public/docs/_examples/router/ts/app/app.routing.6.ts rename public/docs/_examples/template-syntax/dart/lib/{my_click_directive.dart => click_directive.dart} (81%) create mode 100644 public/docs/_examples/template-syntax/dart/lib/sizer_component.dart rename public/docs/_examples/template-syntax/ts/app/{my-click.directive.ts => click.directive.ts} (76%) rename public/docs/_examples/toh-5/dart/lib/{dashboard_component.1.html => dashboard_component_1.html} (100%) diff --git a/.gitignore b/.gitignore index 2666d27c27..df612cd56e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ public/docs/xref-*.* _zip-output www* npm-debug*.log* +**/debug.log *.plnkr.html plnkr.html *.eplnkr.html diff --git a/.travis.yml b/.travis.yml index 394e81297a..2e3b260e29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - DBUS_SESSION_BUS_ADDRESS=/dev/null - DISPLAY=:99.0 - CHROME_BIN=chromium-browser - - LATEST_RELEASE=2.1.1 + - LATEST_RELEASE=2.2.0 - TASK_FLAGS="--dgeni-log=warn" matrix: - TASK=lint diff --git a/gulpfile.js b/gulpfile.js index 6dac9d40c4..765dd3e006 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -247,15 +247,16 @@ function findAndRunE2eTests(filter, outputFile) { e2eSpecPaths.forEach(function(specPath) { // get all of the examples under each dir where a pcFilename is found localExamplePaths = getExamplePaths(specPath, true); - // Filter by language - localExamplePaths = localExamplePaths.filter(function (fn) { - return fn.match('/'+lang+'$') != null; - }); + // Filter by example name if (filter) { localExamplePaths = localExamplePaths.filter(function (fn) { return fn.match(filter) != null; }) } + // Filter by language, also supports variations like js-es6 + localExamplePaths = localExamplePaths.filter(function (fn) { + return fn.match('/'+lang+'(?:-[^/]*)?$') != null; + }); localExamplePaths.forEach(function(examplePath) { examplePaths.push(examplePath); }) @@ -754,7 +755,7 @@ gulp.task('check-deploy', ['firebase-use-proj-check', 'build-docs'], () => { }).then(function(shouldDeploy) { if (shouldDeploy) { gutil.log('deploying...'); - return execPromise(`firebase deploy -p ${WWW}`); + return execPromise('firebase deploy'); } else { return ['Not deploying']; } @@ -1270,7 +1271,7 @@ function apiExamplesWatch(postShredAction) { } function devGuideExamplesWatch(shredOptions, postShredAction, focus) { - var watchPattern = focus ? '**/{' + focus + ',cb-' + focus+ '}/**/*.*' : '**/*.*'; + var watchPattern = focus ? '{' + focus + ',cb-' + focus+ '}/**/*.*' : '**/*.*'; var includePattern = path.join(shredOptions.examplesDir, watchPattern); // removed this version because gulp.watch has the same glob issue that dgeni has. // var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*'); diff --git a/harp.json b/harp.json index ff594edf74..0dd8a50777 100644 --- a/harp.json +++ b/harp.json @@ -29,7 +29,7 @@ "picture": "/resources/images/bios/naomi.jpg", "twitter": "naomitraveller", "website": "http://google.com/+NaomiBlack", - "bio": "Naomi is Angular's TPM generalist and jack-of-all-trades. She leads Angular Material and AngularDart, and acts as webmaster for angular.io. She's been at Google since 2006, as a technical program manager on projects ranging from Accessibility to Google Transit. She fights daleks in her spare time.", + "bio": "Naomi is Angular's TPM generalist and jack-of-all-trades. She leads Angular's global programs (including localization), supports Angular's internal Google users, and acts as webmaster for angular.io and angular.cn. She's been at Google since 2006, as a technical program manager on projects ranging from Accessibility to Google Transit. She fights daleks in her spare time.", "type": "Lead" }, @@ -38,7 +38,7 @@ "picture": "/resources/images/bios/brad-green.jpg", "twitter": "bradlygreen", "website": "https://plus.google.com/+BradGreen", - "bio": "Brad Green works at Google as an engineering director. Brad manages the Google Sales Platform suite of projects as well as the AngularJS framework. Prior to Google, Brad worked on the early mobile web at AvantGo, founded and sold startups, and spent a few hard years toiling as a caterer. Brad's first job out of school was as lackey to Steve Jobs at NeXT Computer writing demo software and designing his slide presentations. Brad lives in Mountain View, CA with his wife and two children.", + "bio": "Brad Green works at Google as an engineering director. Brad manages the Google Sales Platform suite of projects as well as the AngularJS framework. Prior to Google, Brad worked on the early mobile web at AvantGo, founded and sold startups, and spent a few hard years toiling as a caterer. Brad's first job out of school was as lackey to Steve Jobs at NeXT Computer writing demo software and designing his slide presentations. Brad enjoys throwing dinner parties with his wife Heather and putting on plays with his children.", "type": "Lead" }, @@ -47,7 +47,7 @@ "picture": "/resources/images/bios/juleskremer.jpg", "twitter": "jules_kremer", "website": "https://plus.google.com/+JulesKremer", - "bio": "Jules is a TPM on the Angular team. When not working with developers, Jules is often bending into pretzel-like shapes, climbing mountains or drinking really awesome beer.", + "bio": "Jules is Head of Angular Developer Relations at Google. When not working with developers, Jules is often bending into pretzel-like shapes, climbing mountains or drinking really awesome beer.", "type": "Lead" }, diff --git a/public/_includes/_footer.jade b/public/_includes/_footer.jade index 5da35ef23f..e2d9af4fac 100644 --- a/public/_includes/_footer.jade +++ b/public/_includes/_footer.jade @@ -20,7 +20,7 @@ div(class="main-footer" data-swiftype-index="false") // TODO: (ericjim) make a libraries page to showcase all angular libraries //li Libraries li About - li Books & Training + li Books & Training li Tools & Libraries li Community li Press Kit diff --git a/public/docs/_examples/.gitignore b/public/docs/_examples/.gitignore index 52b370600f..3d007625ef 100644 --- a/public/docs/_examples/.gitignore +++ b/public/docs/_examples/.gitignore @@ -11,6 +11,7 @@ wallaby.js _test-output **/ts/**/*.js +**/js-es6*/**/*.js **/ts-snippets/**/*.js *.d.ts diff --git a/public/docs/_examples/_boilerplate/package.json b/public/docs/_examples/_boilerplate/package.json index 3f255fcbd6..bcccdd978a 100644 --- a/public/docs/_examples/_boilerplate/package.json +++ b/public/docs/_examples/_boilerplate/package.json @@ -18,6 +18,7 @@ "build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail", "build:cli": "ng build", "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js", + "build:babel": "babel app -d app --extensions \".es6\" --source-maps", "copy-dist-files": "node ./copy-dist-files.js", "i18n": "ng-xi18n" }, diff --git a/public/docs/_examples/cb-ts-to-js/e2e-spec.ts b/public/docs/_examples/cb-ts-to-js/e2e-spec.ts index 5862beeebf..bc67bac8f0 100644 --- a/public/docs/_examples/cb-ts-to-js/e2e-spec.ts +++ b/public/docs/_examples/cb-ts-to-js/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; @@ -9,7 +9,7 @@ describe('TypeScript to Javascript tests', function () { }); it('should display the basic component example', function () { - testTag('hero-view', 'Hero: Windstorm'); + testTag('hero-view', 'Hero Detail: Windstorm'); }); it('should display the component example with lifecycle methods', function () { @@ -36,7 +36,7 @@ describe('TypeScript to Javascript tests', function () { it('should support component with inputs and outputs', function () { let app = element(by.css('hero-io')); - let confirmComponent = app.element(by.css('my-confirm')); + let confirmComponent = app.element(by.css('app-confirm')); confirmComponent.element(by.buttonText('OK')).click(); expect(app.element(by.cssContainingText('span', 'OK clicked')).isPresent()).toBe(true); @@ -46,11 +46,11 @@ describe('TypeScript to Javascript tests', function () { }); it('should support host bindings and host listeners', function() { - let app = element(by.css('heroes-bindings')); + let app = element(by.css('hero-host')); let h1 = app.element(by.css('h1')); expect(app.getAttribute('class')).toBe('heading'); - expect(app.getAttribute('title')).toBe('Tooltip content'); + expect(app.getAttribute('title')).toContain('Tooltip'); h1.click(); expect(h1.getAttribute('class')).toBe('active'); @@ -61,12 +61,12 @@ describe('TypeScript to Javascript tests', function () { }); it('should support content and view queries', function() { - let app = element(by.css('heroes-queries')); - let windstorm = app.element(by.css('a-hero:first-child')); + let app = element(by.css('hero-queries')); + let windstorm = app.element(by.css('view-child:first-child')); - app.element(by.buttonText('Activate')).click(); + app.element(by.css('button')).click(); expect(windstorm.element(by.css('h2')).getAttribute('class')).toBe('active'); - expect(windstorm.element(by.css('active-label')).getText()).toBe('Active'); + expect(windstorm.element(by.css('content-child')).getText()).toBe('Active'); }); function testTag(selector: string, expectedText: string) { diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/.babelrc b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/.babelrc new file mode 100644 index 0000000000..3aaf507508 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "es2015", + "angular2" + ] +} diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.es6 new file mode 100644 index 0000000000..e5f158dbed --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.es6 @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; + +@Component({ + moduleId: module.id, + selector: 'my-app', + templateUrl: 'app.component.html', + styles: [ + // See hero-di-inject-additional.component + 'hero-host, hero-host-meta { border: 1px dashed black; display: block; padding: 4px;}', + '.heading {font-style: italic}' + ] +}) +export class AppComponent { + title = 'ES6 JavaScript with Decorators'; +} diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.html b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.html new file mode 100644 index 0000000000..7f1efd31a0 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.component.html @@ -0,0 +1,31 @@ + +

{{title}}

+Classes and Class Metadata
+Input and Output Decorators
+Dependency Injection
+Host Metadata
+View and Child Metadata
+ +
+

Classes and Class Metadata

+ + + +
+

Input and Output Metadata

+ + +
+

Dependency Injection

+ + + + +
+

Host Metadata

+ + + +
+

View and Child Metadata

+ diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.module.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.module.es6 new file mode 100644 index 0000000000..bea55777ef --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/app.module.es6 @@ -0,0 +1,55 @@ +import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; + +import { AppComponent } from './app.component'; +import { ConfirmComponent } from './confirm.component'; +// #docregion appimport +import { HeroComponent } from './hero.component'; +// #enddocregion appimport +import { HeroComponent as HeroDIComponent } from './hero-di.component'; +import { HeroComponent as HeroDIInjectComponent } from './hero-di-inject.component'; +import { HeroComponent as HeroDIInjectAdditionalComponent } from './hero-di-inject-additional.component'; +import { HeroHostComponent } from './hero-host.component'; +import { HeroHostMetaComponent } from './hero-host-meta.component'; +import { HeroIOComponent } from './hero-io.component'; +import { HeroComponent as HeroLifecycleComponent } from './hero-lifecycle.component'; +import { HeroQueriesComponent, ViewChildComponent, ContentChildComponent } from './hero-queries.component'; +import { HeroTitleComponent } from './hero-title.component'; + +import { DataService } from './data.service'; + +@NgModule({ + imports: [ + BrowserModule + ], + declarations: [ + AppComponent, + ConfirmComponent, + HeroComponent, + HeroDIComponent, + HeroDIInjectComponent, + HeroDIInjectAdditionalComponent, + HeroHostComponent, HeroHostMetaComponent, + HeroIOComponent, + HeroLifecycleComponent, + HeroQueriesComponent, ViewChildComponent, ContentChildComponent, + HeroTitleComponent + ], + providers: [ + DataService, + { provide: 'heroName', useValue: 'Windstorm' } + ], + bootstrap: [ AppComponent ], + + // schemas: [ NO_ERRORS_SCHEMA ] // helpful for debugging +}) +export class AppModule { } + +/* tslint:disable no-unused-variable */ +// #docregion ng2import +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { + LocationStrategy, + HashLocationStrategy +} from '@angular/common'; +// #enddocregion ng2import diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.es6 new file mode 100644 index 0000000000..08a0ed6c60 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/confirm.component.es6 @@ -0,0 +1,22 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +// #docregion +@Component({ + moduleId: module.id, + selector: 'app-confirm', + templateUrl: 'confirm.component.html' +}) +export class ConfirmComponent { + @Input() okMsg = ''; + @Input('cancelMsg') notOkMsg = ''; + @Output() ok = new EventEmitter(); + @Output('cancel') notOk = new EventEmitter(); + + onOkClick() { + this.ok.emit(true); + } + onNotOkClick() { + this.notOk.emit(true); + } +} +// #enddocregion 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/data.service.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/data.service.es6 new file mode 100644 index 0000000000..cd7f9e1aae --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/data.service.es6 @@ -0,0 +1,10 @@ +import { Injectable } from '@angular/core'; + +@Injectable() +export class DataService { + constructor() { } + + getHeroName() { + return 'Windstorm'; + } +} 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 new file mode 100644 index 0000000000..ec460a9dbc --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject-additional.component.es6 @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'hero-di-inject-additional', + template: `` +}) +export class HeroComponent { } diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject.component.es6 new file mode 100644 index 0000000000..94b42f956a --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di-inject.component.es6 @@ -0,0 +1,13 @@ +import { Component, Inject } from '@angular/core'; + +// #docregion +@Component({ + selector: 'hero-di-inject', + template: `

Hero: {{name}}

` +}) +export class HeroComponent { + constructor(@Inject('heroName') name) { + this.name = name; + } +} +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di.component.es6 new file mode 100644 index 0000000000..0cc78d277e --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-di.component.es6 @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; +import { DataService } from './data.service'; + +// #docregion +@Component({ + selector: 'hero-di', + template: `

Hero: {{name}}

` +}) +export class HeroComponent { + name = ''; + constructor(dataService: DataService) { + this.name = dataService.getHeroName(); + } +} +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host-meta.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host-meta.component.es6 new file mode 100644 index 0000000000..25dbe1c21a --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host-meta.component.es6 @@ -0,0 +1,44 @@ +import { Component } from '@angular/core'; + +// #docregion +@Component({ + selector: 'hero-host-meta', + template: ` +

Hero Host in Metadata

+
Heading clicks: {{clicks}}
+ `, + host: { + // HostBindings to the element + '[title]': 'title', + '[class.heading]': 'headingClass', + + // HostListeners on the entire element + '(click)': 'clicked()', + '(mouseenter)': 'enter($event)', + '(mouseleave)': 'leave($event)' + }, + // Styles within (but excluding) the element + styles: ['.active {background-color: coral;}'] +}) +export class HeroHostMetaComponent { + title = 'Hero Host in Metadata Tooltip'; + headingClass = true; + + active = false; + clicks = 0; + + clicked() { + this.clicks += 1; + } + + enter(event: Event) { + this.active = true; + this.headingClass = false; + } + + leave(event: Event) { + this.active = false; + this.headingClass = true; + } +} +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host.component.es6 new file mode 100644 index 0000000000..e8d72233c8 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-host.component.es6 @@ -0,0 +1,39 @@ +import { Component, HostBinding, HostListener } from '@angular/core'; + +// #docregion +@Component({ + selector: 'hero-host', + template: ` +

Hero Host in Decorators

+
Heading clicks: {{clicks}}
+ `, + // Styles within (but excluding) the element + styles: ['.active {background-color: yellow;}'] +}) +export class HeroHostComponent { + // HostBindings to the element + @HostBinding() title = 'Hero Host in Decorators Tooltip'; + @HostBinding('class.heading') headingClass = true; + + active = false; + clicks = 0; + + // HostListeners on the entire element + @HostListener('click') + clicked() { + this.clicks += 1; + } + + @HostListener('mouseenter', ['$event']) + enter(event: Event) { + this.active = true; + this.headingClass = false; + } + + @HostListener('mouseleave', ['$event']) + leave(event: Event) { + this.active = false; + this.headingClass = true; + } +} +// #enddocregion 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 new file mode 100644 index 0000000000..4b36411e78 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6 @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'hero-io', + template: ` + + + OK clicked + Cancel clicked + ` +}) +export class HeroIOComponent { + okClicked = false; + cancelClicked = false; + + onOk() { + this.okClicked = true; + } + + onCancel() { + this.cancelClicked = true; + } +} diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-lifecycle.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-lifecycle.component.es6 new file mode 100644 index 0000000000..2539266597 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-lifecycle.component.es6 @@ -0,0 +1,14 @@ +// #docregion +import { Component } from '@angular/core'; + +@Component({ + selector: 'hero-lifecycle', + template: `

Hero: {{name}}

` +}) +export class HeroComponent { + name = ''; + ngOnInit() { + // todo: fetch from server async + setTimeout(() => this.name = 'Windstorm', 0); + } +} diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-queries.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-queries.component.es6 new file mode 100644 index 0000000000..fced43d4d7 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-queries.component.es6 @@ -0,0 +1,81 @@ +import { + Component, + ContentChild, + Input, + QueryList, + ViewChildren +} from '@angular/core'; + +@Component({ + selector: 'content-child', + template: ` + + Active + ` +}) +export class ContentChildComponent { + active = false; + + activate() { + this.active = true; + } +} + +//////////////////// + +// #docregion content +@Component({ + selector: 'view-child', + template: ` +

+ {{hero.name}} + +

`, + styles: ['.active {font-weight: bold; background-color: skyblue;}'] +}) +export class ViewChildComponent { + @Input() hero; + active = false; + + @ContentChild(ContentChildComponent) content; + + activate() { + this.active = !this.active; + this.content.activate(); + } +} +// #enddocregion content + +//////////////////// + +// #docregion view +@Component({ + selector: 'hero-queries', + template: ` + + + + + ` +}) +export class HeroQueriesComponent { + active = false; + heroData = [ + {id: 1, name: 'Windstorm'}, + {id: 2, name: 'LaughingGas'} + ]; + + @ViewChildren(ViewChildComponent) views; + + activate() { + this.active = !this.active; + this.views.forEach( + view => view.activate() + ); + } + + get buttonLabel() { + return this.active ? 'Deactivate' : 'Activate'; + } +} +// #enddocregion view diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.es6 new file mode 100644 index 0000000000..25460d34f7 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.es6 @@ -0,0 +1,26 @@ +import { Attribute, Component, Inject, Optional } from '@angular/core'; + +// #docregion +// #docregion templateUrl +@Component({ + moduleId: module.id, + selector: 'hero-title', + templateUrl: 'hero-title.component.html' +}) +// #enddocregion templateUrl +export class HeroTitleComponent { + msg = ''; + constructor( + @Inject('titlePrefix') @Optional() titlePrefix, + @Attribute('title') title + ) { + this.titlePrefix = titlePrefix; + this.title = title; + } + + ok() { + this.msg = 'OK!'; + } +} +// #enddocregion + diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.html b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.html new file mode 100644 index 0000000000..0e93122d5c --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero-title.component.html @@ -0,0 +1,4 @@ + +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero.component.es6 new file mode 100644 index 0000000000..4ea4c11611 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/hero.component.es6 @@ -0,0 +1,14 @@ +// #docregion metadata +import { Component } from '@angular/core'; + +@Component({ + selector: 'hero-view', + template: '

{{title}}: {{getName()}}

' +}) +// #docregion appexport, class +export class HeroComponent { + title = 'Hero Detail'; + getName() {return 'Windstorm'; } +} +// #enddocregion appexport, class +// #enddocregion metadata diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/main.es6 b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/main.es6 new file mode 100644 index 0000000000..2470c9595e --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/app/main.es6 @@ -0,0 +1,4 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { AppModule } from './app.module'; + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/example-config.json b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/example-config.json new file mode 100644 index 0000000000..391bd1a766 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/example-config.json @@ -0,0 +1,4 @@ +{ + "build": "build:babel", + "run": "http-server:e2e" +} \ No newline at end of file diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/index.html b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/index.html new file mode 100644 index 0000000000..1b9e3b5211 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/index.html @@ -0,0 +1,27 @@ + + + + + + + + TypeScript to JavaScript + + + + + + + + + + + + + + Loading... + + + diff --git a/public/docs/_examples/cb-ts-to-js/js-es6-decorators/plnkr.json b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/plnkr.json new file mode 100644 index 0000000000..5c7a5acd44 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6-decorators/plnkr.json @@ -0,0 +1,8 @@ +{ + "description": "TypeScript to JavaScript", + "files":[ + "!**/*.d.ts", + "!**/*.js" + ], + "tags":["cookbook"] +} diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/.babelrc b/public/docs/_examples/cb-ts-to-js/js-es6/.babelrc new file mode 100644 index 0000000000..3c078e9f99 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "es2015" + ] +} diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.es6 new file mode 100644 index 0000000000..9615b98a1f --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.es6 @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; + +export class AppComponent { + constructor() { + this.title = 'Plain ES6 JavaScript'; + } +} + +AppComponent.annotations = [ + new Component({ + moduleId: module.id, + selector: 'my-app', + templateUrl: 'app.component.html', + styles: [ + // See hero-di-inject-additional.component + 'hero-host { border: 1px dashed black; display: block; padding: 4px;}', + '.heading {font-style: italic}' + ] + }) +]; diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.html b/public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.html new file mode 100644 index 0000000000..8fbe65ade6 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/app.component.html @@ -0,0 +1,30 @@ + +

{{title}}

+Classes and Class Metadata
+Input and Output Metadata
+Dependency Injection
+Host Metadata
+View and Child Metadata
+ +
+

Classes and Class Metadata

+ + + +
+

Input and Output Metadata

+ + +
+

Dependency Injection

+ + + + +
+

Host Metadata

+ + +
+

View and Child Metadata

+ diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/app.module.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/app.module.es6 new file mode 100644 index 0000000000..e8c7a8f9c8 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/app.module.es6 @@ -0,0 +1,56 @@ +import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; + +import { AppComponent } from './app.component'; +import { ConfirmComponent } from './confirm.component'; +// #docregion appimport +import { HeroComponent } from './hero.component'; + +// #enddocregion appimport +import { HeroComponent as HeroDIComponent } from './hero-di.component'; +import { HeroComponent as HeroDIInjectComponent } from './hero-di-inject.component'; +import { HeroComponent as HeroDIInjectAdditionalComponent } from './hero-di-inject-additional.component'; +import { HeroHostComponent } from './hero-host.component'; +import { HeroIOComponent } from './hero-io.component'; +import { HeroComponent as HeroLifecycleComponent } from './hero-lifecycle.component'; +import { HeroQueriesComponent, ViewChildComponent, ContentChildComponent } from './hero-queries.component'; +import { HeroTitleComponent } from './hero-title.component'; + +import { DataService } from './data.service'; + +export class AppModule { } + +AppModule.annotations = [ + new NgModule({ + imports: [ BrowserModule], + declarations: [ + AppComponent, + ConfirmComponent, + HeroComponent, + HeroDIComponent, + HeroDIInjectComponent, + HeroDIInjectAdditionalComponent, + HeroHostComponent, + HeroIOComponent, + HeroLifecycleComponent, + HeroQueriesComponent, ViewChildComponent, ContentChildComponent, + HeroTitleComponent + ], + providers: [ + DataService, + { provide: 'heroName', useValue: 'Windstorm' } + ], + bootstrap: [ AppComponent ], + + // schemas: [ NO_ERRORS_SCHEMA ] // helpful for debugging + }) +] + +/* tslint:disable no-unused-variable */ +// #docregion ng2import +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { + LocationStrategy, + HashLocationStrategy +} from '@angular/common'; +// #enddocregion ng2import diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.es6 new file mode 100644 index 0000000000..d42a553688 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/confirm.component.es6 @@ -0,0 +1,32 @@ +import { Component, EventEmitter } from '@angular/core'; + +// #docregion +export class ConfirmComponent { + constructor(){ + this.ok = new EventEmitter(); + this.notOk = new EventEmitter(); + } + onOkClick() { + this.ok.emit(true); + } + onNotOkClick() { + this.notOk.emit(true); + } +} + +ConfirmComponent.annotations = [ + new Component({ + moduleId: module.id, + selector: 'app-confirm', + templateUrl: 'confirm.component.html', + inputs: [ + 'okMsg', + 'notOkMsg: cancelMsg' + ], + outputs: [ + 'ok', + 'notOk: cancel' + ] + }) +]; +// #enddocregion 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/data.service.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/data.service.es6 new file mode 100644 index 0000000000..de023ce5a0 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/data.service.es6 @@ -0,0 +1,13 @@ +import { Injectable } from '@angular/core'; + +export class DataService { + constructor() { + } + getHeroName() { + return 'Windstorm'; + } +} + +DataService.annotations = [ + new Injectable() +]; 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 new file mode 100644 index 0000000000..5eb9bab815 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6 @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +export class HeroComponent { } + +HeroComponent.annotations = [ + new Component({ + selector: 'hero-di-inject-additional', + template: `` + }) +]; diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject.component.es6 new file mode 100644 index 0000000000..2f95a0b981 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject.component.es6 @@ -0,0 +1,20 @@ +import { Component, Inject } from '@angular/core'; + +// #docregion +export class HeroComponent { + constructor(name) { + this.name = name; + } +} + +HeroComponent.annotations = [ + new Component({ + selector: 'hero-di-inject', + template: `

Hero: {{name}}

` + }) +]; + +HeroComponent.parameters = [ + [new Inject('heroName')] +]; +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di.component.es6 new file mode 100644 index 0000000000..dfbecf0707 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di.component.es6 @@ -0,0 +1,22 @@ +import { Component } from '@angular/core'; +import { DataService } from './data.service'; + +// #docregion +export class HeroComponent { + constructor(dataService) { + this.name = dataService.getHeroName(); + } +} + +HeroComponent.annotations = [ + new Component({ + selector: 'hero-di', + template: `

Hero: {{name}}

` + }) +]; + +HeroComponent.parameters = [ + [DataService] +]; + +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-host.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-host.component.es6 new file mode 100644 index 0000000000..092cd1a1ce --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-host.component.es6 @@ -0,0 +1,50 @@ +import { Component } from '@angular/core'; + +// #docregion +export class HeroHostComponent { + constructor() { + this.active = false; + this.clicks = 0; + this.headingClass = true; + this.title = 'Hero Host Tooltip'; + } + + clicked() { + this.clicks += 1; + } + + enter(event) { + this.active = true; + this.headingClass = false; + } + + leave(event) { + this.active = false; + this.headingClass = true; + } +} + +// #docregion metadata +HeroHostComponent.annotations = [ + new Component({ + selector: 'hero-host', + template: ` +

Hero Host

+
Heading clicks: {{clicks}}
+ `, + host: { + // HostBindings to the element + '[title]': 'title', + '[class.heading]': 'headingClass', + '(click)': 'clicked()', + + // HostListeners on the entire element + '(mouseenter)': 'enter($event)', + '(mouseleave)': 'leave($event)' + }, + // Styles within (but excluding) the element + styles: ['.active {background-color: yellow;}'] + }) +]; +// #docregion metadata +// #enddocregion 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 new file mode 100644 index 0000000000..0dc8c08f2d --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-io.component.es6 @@ -0,0 +1,31 @@ +import { Component } from '@angular/core'; + +export class HeroIOComponent { + constructor() { + this.okClicked = false; + this.cancelClicked = false; + } + + onOk() { + this.okClicked = true; + } + + onCancel() { + this.cancelClicked = true; + } +} + +HeroIOComponent.annotations = [ + new Component({ + selector: 'hero-io', + template: ` + + + OK clicked + Cancel clicked + ` + }) +]; diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-lifecycle.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-lifecycle.component.es6 new file mode 100644 index 0000000000..b394ff59aa --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-lifecycle.component.es6 @@ -0,0 +1,15 @@ +// #docregion +import { Component } from '@angular/core'; +export class HeroComponent { + ngOnInit() { + // todo: fetch from server async + setTimeout(() => this.name = 'Windstorm', 0); + } +} + +HeroComponent.annotations = [ + new Component({ + selector: 'hero-lifecycle', + template: `

Hero: {{name}}

` + }) +]; diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-queries.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-queries.component.es6 new file mode 100644 index 0000000000..bf3b914406 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-queries.component.es6 @@ -0,0 +1,97 @@ +import { + Component, + ContentChild, + Input, + QueryList, + ViewChildren +} from '@angular/core'; + +export class ContentChildComponent { + constructor() { + this.active = false; + } + + activate() { + this.active = !this.active; + } +} + +ContentChildComponent.annotations = [ + new Component({ + selector: 'content-child', + template: ` + + Active + ` + }) +]; + +//////////////////// + +// #docregion content +export class ViewChildComponent { + constructor() { + this.active = false; + } + + activate() { + this.active = !this.active; + this.content.activate(); + } +} + +ViewChildComponent.annotations = [ + new Component({ + selector: 'view-child', + template: `

+ {{hero.name}} + +

`, + styles: ['.active {font-weight: bold; background-color: skyblue;}'], + inputs: ['hero'], + queries: { + content: new ContentChild(ContentChildComponent) + } + }) +]; +// #enddocregion content + +//////////////////// + +// #docregion view +export class HeroQueriesComponent { + constructor(){ + this.active = false; + this.heroData = [ + {id: 1, name: 'Windstorm'}, + {id: 2, name: 'LaughingGas'} + ]; + } + + activate() { + this.active = !this.active; + this.views.forEach( + view => view.activate() + ); + } + + get buttonLabel() { + return this.active ? 'Deactivate' : 'Activate'; + } +} + +HeroQueriesComponent.annotations = [ + new Component({ + selector: 'hero-queries', + template: ` + + + + + `, + queries: { + views: new ViewChildren(ViewChildComponent) + } + }) +]; +// #enddocregion view diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.es6 new file mode 100644 index 0000000000..ff1e6ce026 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.es6 @@ -0,0 +1,29 @@ +import { Attribute, Component, Inject, Optional } from '@angular/core'; + +// #docregion +export class HeroTitleComponent { + constructor(titlePrefix, title) { + this.titlePrefix = titlePrefix; + this.title = title; + this.msg = ''; + } + + ok() { + this.msg = 'OK!'; + } +} + +// #docregion templateUrl +HeroTitleComponent.annotations = [ + new Component({ + moduleId: module.id, + selector: 'hero-title', + templateUrl: 'hero-title.component.html' + }) +]; +// #enddocregion templateUrl + +HeroTitleComponent.parameters = [ + [new Optional(), new Inject('titlePrefix')], + [new Attribute('title')] +]; diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.html b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.html new file mode 100644 index 0000000000..0e93122d5c --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-title.component.html @@ -0,0 +1,4 @@ + +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/hero.component.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero.component.es6 new file mode 100644 index 0000000000..10b92c2878 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/hero.component.es6 @@ -0,0 +1,20 @@ +// #docplaster +// #docregion metadata +import { Component } from '@angular/core'; + +// #docregion appexport, class +export class HeroComponent { + constructor() { + this.title = 'Hero Detail'; + } + getName() {return 'Windstorm'; } +} +// #enddocregion appexport, class + +HeroComponent.annotations = [ + new Component({ + selector: 'hero-view', + template: '

{{title}}: {{getName()}}

' + }) +]; +// #enddocregion metadata diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/app/main.es6 b/public/docs/_examples/cb-ts-to-js/js-es6/app/main.es6 new file mode 100644 index 0000000000..2470c9595e --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/app/main.es6 @@ -0,0 +1,4 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { AppModule } from './app.module'; + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/example-config.json b/public/docs/_examples/cb-ts-to-js/js-es6/example-config.json new file mode 100644 index 0000000000..391bd1a766 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/example-config.json @@ -0,0 +1,4 @@ +{ + "build": "build:babel", + "run": "http-server:e2e" +} \ No newline at end of file diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/index.html b/public/docs/_examples/cb-ts-to-js/js-es6/index.html new file mode 100644 index 0000000000..1b9e3b5211 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/index.html @@ -0,0 +1,27 @@ + + + + + + + + TypeScript to JavaScript + + + + + + + + + + + + + + Loading... + + + diff --git a/public/docs/_examples/cb-ts-to-js/js-es6/plnkr.json b/public/docs/_examples/cb-ts-to-js/js-es6/plnkr.json new file mode 100644 index 0000000000..5c7a5acd44 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js-es6/plnkr.json @@ -0,0 +1,8 @@ +{ + "description": "TypeScript to JavaScript", + "files":[ + "!**/*.d.ts", + "!**/*.js" + ], + "tags":["cookbook"] +} diff --git a/public/docs/_examples/cb-ts-to-js/js/app/app.component.html b/public/docs/_examples/cb-ts-to-js/js/app/app.component.html new file mode 100644 index 0000000000..6681d60672 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/app.component.html @@ -0,0 +1,47 @@ + +

{{title}}

+Classes and Class Metadata
+Interfaces
+Input and Output Metadata
+Dependency Injection
+Host Metadata
+View and Child Metadata
+ +
+

Classes and Class Metadata

+ +

Classes and Class Metadata (DSL)

+ + +
+

Interfaces

+ +

Interfaces (DSL)

+ + +
+

Input and Output Metadata

+ +

Input and Output Metadata (DSL)

+ + +
+

Dependency Injection

+ + + + +

Dependency Injection (DSL)

+ + + + +
+

Host Metadata

+ +

Host Metadata (DSL)

+ + +
+

View and Child Metadata (DSL)

+ diff --git a/public/docs/_examples/cb-ts-to-js/js/app/app.component.js b/public/docs/_examples/cb-ts-to-js/js/app/app.component.js new file mode 100644 index 0000000000..9e8c5da535 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/app.component.js @@ -0,0 +1,20 @@ +(function(app) { + +app.AppComponent = AppComponent; +function AppComponent() { + this.title = 'ES5 JavaScript'; +} + +AppComponent.annotations = [ + new ng.core.Component({ + selector: 'my-app', + templateUrl: 'app/app.component.html', + styles: [ + // See hero-di-inject-additional.component + 'hero-host, hero-host-dsl { border: 1px dashed black; display: block; padding: 4px;}', + '.heading {font-style: italic}' + ] + }) +]; + +})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/app.module.js b/public/docs/_examples/cb-ts-to-js/js/app/app.module.js new file mode 100644 index 0000000000..3791fe16da --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/app.module.js @@ -0,0 +1,46 @@ +(function(app) { + +app.AppModule = AppModule; +function AppModule() { } + +AppModule.annotations = [ + new ng.core.NgModule({ + imports: [ ng.platformBrowser.BrowserModule ], + declarations: [ + app.AppComponent, + app.ConfirmComponent, app.ConfirmDslComponent, + app.HeroComponent, app.HeroDslComponent, + app.HeroDIComponent, app.HeroDIDslComponent, + app.HeroDIInjectComponent, app.HeroDIInjectDslComponent, + app.HeroDIInjectAdditionalComponent, app.HeroDIInjectAdditionalDslComponent, + app.HeroHostComponent, app.HeroHostDslComponent, + app.HeroIOComponent, app.HeroIODslComponent, + app.HeroLifecycleComponent, app.HeroLifecycleDslComponent, + app.heroQueries.HeroQueriesComponent, app.heroQueries.ViewChildComponent, app.heroQueries.ContentChildComponent, + app.HeroTitleComponent, app.HeroTitleDslComponent + ], + providers: [ + app.DataService, + { provide: 'heroName', useValue: 'Windstorm' } + ], + bootstrap: [ app.AppComponent ], + + // schemas: [ ng.core.NO_ERRORS_SCHEMA ] // helpful for debugging! + }) +] + +})(window.app = window.app || {}); + + +///// For documentation only ///// +(function () { + // #docregion appimport + var HeroComponent = app.HeroComponent; + // #enddocregion appimport + + // #docregion ng2import + var platformBrowserDynamic = ng.platformBrowserDynamic.platformBrowserDynamic; + var LocationStrategy = ng.common.LocationStrategy; + var HashLocationStrategy = ng.common.HashLocationStrategy; + // #enddocregion ng2import +}) 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/confirm.component.js b/public/docs/_examples/cb-ts-to-js/js/app/confirm.component.js new file mode 100644 index 0000000000..4a4cd0a470 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/confirm.component.js @@ -0,0 +1,73 @@ +(function(app) { + +// #docregion +app.ConfirmComponent = ConfirmComponent; + +ConfirmComponent.annotations = [ + new ng.core.Component({ + selector: 'app-confirm', + templateUrl: 'app/confirm.component.html', + inputs: [ + 'okMsg', + 'notOkMsg: cancelMsg' + ], + outputs: [ + 'ok', + 'notOk: cancel' + ] + }) +]; + +function ConfirmComponent() { + this.ok = new ng.core.EventEmitter(); + this.notOk = new ng.core.EventEmitter(); +} + +ConfirmComponent.prototype.onOkClick = function() { + this.ok.emit(true); +} + +ConfirmComponent.prototype.onNotOkClick = function() { + this.notOk.emit(true); +} + + +// #enddocregion + +})(window.app = window.app || {}); + +/////// DSL version //////// + +(function(app) { + +// #docregion dsl +app.ConfirmDslComponent = ng.core.Component({ + selector: 'app-confirm-dsl', + templateUrl: 'app/confirm.component.html', + inputs: [ + 'okMsg', + 'notOkMsg: cancelMsg' + ], + outputs: [ + 'ok', + 'notOk: cancel' + ] + }) + .Class({ + constructor: function ConfirmDslComponent() { + this.ok = new ng.core.EventEmitter(); + this.notOk = new ng.core.EventEmitter(); + }, + + onOkClick: function() { + this.ok.emit(true); + }, + + onNotOkClick: function() { + this.notOk.emit(true); + } + }); + +// #enddocregion dsl + +})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/data.service.js b/public/docs/_examples/cb-ts-to-js/js/app/data.service.js index c060e2b39d..643bb57dca 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/data.service.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/data.service.js @@ -1,13 +1,10 @@ (function(app) { - function DataService() { - } - DataService.annotations = [ - new ng.core.Injectable() - ]; + app.DataService = DataService; + function DataService() { } + DataService.prototype.getHeroName = function() { return 'Windstorm'; }; - app.DataService = DataService; })(window.app = window.app || {}); 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 fa9684e7a1..1a88cfa355 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,50 +1,26 @@ (function(app) { - // #docregion - var TitleComponent = ng.core.Component({ - selector: 'hero-title', - template: - '

{{titlePrefix}} {{title}}

' + - '' + - '

{{ msg }}

' - }).Class({ - constructor: [ - [ - new ng.core.Optional(), - new ng.core.Inject('titlePrefix') - ], - new ng.core.Attribute('title'), - function(titlePrefix, title) { - this.titlePrefix = titlePrefix; - this.title = title; - this.msg = ''; - } - ], - ok: function() { - this.msg = 'OK!'; - } - }); - // #enddocregion +app.HeroDIInjectAdditionalComponent = HeroDIInjectAdditionalComponent; - var AppComponent = ng.core.Component({ +HeroDIInjectAdditionalComponent.annotations = [ + new ng.core.Component({ selector: 'hero-di-inject-additional', - template: '' + - '' - }).Class({ - constructor: function() { } - }); - - app.HeroesDIInjectAdditionalModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ - AppComponent, - TitleComponent - ], - bootstrap: [ AppComponent ] - }) - .Class({ - constructor: function() {} - }); + template: '' + }) +]; + +function HeroDIInjectAdditionalComponent() {} + +})(window.app = window.app || {}); + +////// DSL Version ///////// +(function(app) { + +app.HeroDIInjectAdditionalDslComponent = ng.core.Component({ + selector: 'hero-di-inject-additional-dsl', + template: '' +}).Class({ + constructor: function HeroDIInjectAdditionalDslComponent() { } +}); })(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject.component.js index dfda83e1f0..2e04c9246e 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject.component.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject.component.js @@ -1,57 +1,41 @@ (function(app) { -// #docregion parameters - function HeroComponent(name) { - this.name = name; - } - HeroComponent.parameters = [ - 'heroName' - ]; - HeroComponent.annotations = [ - new ng.core.Component({ - selector: 'hero-di-inject', - template: '

Hero: {{name}}

' - }) - ]; -// #enddocregion parameters +// #docregion +app.HeroDIInjectComponent = HeroDIInjectComponent; - app.HeroesDIInjectModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - providers: [ { provide: 'heroName', useValue: 'Windstorm' } ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); - -})(window.app = window.app || {}); - -(function(app) { -// #docregion ctor - var HeroComponent = ng.core.Component({ - selector: 'hero-di-inline2', +HeroDIInjectComponent.annotations = [ + new ng.core.Component({ + selector: 'hero-di-inject', template: '

Hero: {{name}}

' }) - .Class({ - constructor: - [new ng.core.Inject('heroName'), - function(name) { - this.name = name; - }] - }); -// #enddocregion ctor +]; - app.HeroesDIInjectModule2 = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - providers: [ { provide: 'heroName', useValue: 'Bombasto' } ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); +HeroDIInjectComponent.parameters = [ 'heroName' ]; + +function HeroDIInjectComponent(name) { + this.name = name; +} +// #enddocregion + +})(window.app = window.app || {}); + +/////// DSL version //////// + +(function(app) { + +// #docregion dsl +app.HeroDIInjectDslComponent = ng.core.Component({ + selector: 'hero-di-inject-dsl', + template: '

Hero: {{name}}

' +}) +.Class({ + constructor: [ + new ng.core.Inject('heroName'), + function HeroDIInjectDslComponent(name) { + this.name = name; + } + ] +}); +// #enddocregion dsl })(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inline.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inline.component.js deleted file mode 100644 index 1fe9c38cb1..0000000000 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inline.component.js +++ /dev/null @@ -1,27 +0,0 @@ -(function(app) { - // #docregion - var HeroComponent = ng.core.Component({ - selector: 'hero-di-inline', - template: '

Hero: {{name}}

' - }) - .Class({ - constructor: - [app.DataService, - function(service) { - this.name = service.getHeroName(); - }] - }); - // #enddocregion - - app.HeroDIInlineModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - providers: [ app.DataService ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); - -})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-di.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-di.component.js index 55c576b836..c80efe193e 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-di.component.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di.component.js @@ -1,31 +1,43 @@ (function(app) { // #docregion - app.HeroDIComponent = HeroComponent; - - function HeroComponent(dataService) { - this.name = dataService.getHeroName(); - } - HeroComponent.parameters = [ - app.DataService - ]; - HeroComponent.annotations = [ + app.HeroDIComponent = HeroDIComponent; + + HeroDIComponent.annotations = [ new ng.core.Component({ selector: 'hero-di', template: '

Hero: {{name}}

' }) ]; + + HeroDIComponent.parameters = [ app.DataService ]; + + function HeroDIComponent(dataService) { + this.name = dataService.getHeroName(); + } + // #enddocregion - app.HeroesDIModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - providers: [ app.DataService ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); + +})(window.app = window.app || {}); + +////// DSL Version ///// + +(function(app) { + +// #docregion dsl +app.HeroDIDslComponent = ng.core.Component({ + selector: 'hero-di-dsl', + template: '

Hero: {{name}}

' +}) +.Class({ + constructor: [ + app.DataService, + function HeroDIDslComponent(service) { + this.name = service.getHeroName(); + } + ] +}); +// #enddocregion dsl })(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-dsl.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-dsl.component.js deleted file mode 100644 index 5dd84733f3..0000000000 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-dsl.component.js +++ /dev/null @@ -1,31 +0,0 @@ -// #docplaster -// #docregion appexport -(function(app) { - - // #docregion component - var HeroComponent = ng.core.Component({ - selector: 'hero-view-2', - template: - '

Name: {{getName()}}

', - }) - .Class({ - constructor: function() { - }, - getName: function() { - return 'Windstorm'; - } - }); - // #enddocregion component - - app.HeroesDslModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); - -})(window.app = window.app || {}); -// #enddocregion appexport diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-host.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-host.component.js new file mode 100644 index 0000000000..0b04d5efae --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-host.component.js @@ -0,0 +1,97 @@ +(function(app) { + +// #docregion +app.HeroHostComponent = HeroHostComponent; + +HeroHostComponent.annotations = [ + new ng.core.Component({ + selector: 'hero-host', + template: + '

Hero Host

' + + '
Heading clicks: {{clicks}}
', + host: { + // HostBindings to the element + '[title]': 'title', + '[class.heading]': 'headingClass', + '(click)': 'clicked()', + + // HostListeners on the entire element + '(mouseenter)': 'enter($event)', + '(mouseleave)': 'leave($event)' + }, + // Styles within (but excluding) the element + styles: ['.active {background-color: yellow;}'] + }) +]; + +function HeroHostComponent() { + this.clicks = 0; + this.headingClass = true; + this.title = 'Hero Host Tooltip content'; +} + +HeroHostComponent.prototype.clicked = function() { + this.clicks += 1; +} + +HeroHostComponent.prototype.enter = function(event) { + this.active = true; + this.headingClass = false; +} + +HeroHostComponent.prototype.leave = function(event) { + this.active = false; + this.headingClass = true; +} +// #enddocregion + +})(window.app = window.app || {}); + +//// DSL Version //// + +(function(app) { + +// #docregion dsl +app.HeroHostDslComponent = ng.core.Component({ + selector: 'hero-host-dsl', + template: ` +

Hero Host (DSL)

+
Heading clicks: {{clicks}}
+ `, + host: { + // HostBindings to the element + '[title]': 'title', + '[class.heading]': 'headingClass', + '(click)': 'clicked()', + + // HostListeners on the entire element + '(mouseenter)': 'enter($event)', + '(mouseleave)': 'leave($event)' + }, + // Styles within (but excluding) the element + styles: ['.active {background-color: coral;}'] +}) +.Class({ + constructor: function HeroHostDslComponent() { + this.clicks = 0; + this.headingClass = true; + this.title = 'Hero Host Tooltip DSL content'; + }, + + clicked() { + this.clicks += 1; + }, + + enter(event) { + this.active = true; + this.headingClass = false; + }, + + leave(event) { + this.active = false; + this.headingClass = true; + } +}); +// #enddocregion dsl + +})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-io-dsl.component.html b/public/docs/_examples/cb-ts-to-js/js/app/hero-io-dsl.component.html new file mode 100644 index 0000000000..48c491be35 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-io-dsl.component.html @@ -0,0 +1,7 @@ + + +OK clicked +Cancel clicked diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.html b/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.html new file mode 100644 index 0000000000..e6eae2e804 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.html @@ -0,0 +1,7 @@ + + +OK clicked +Cancel clicked 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..d35f3762da 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 @@ -1,68 +1,42 @@ (function(app) { - // #docregion - var ConfirmComponent = ng.core.Component({ - selector: 'my-confirm', - inputs: [ - 'okMsg', - 'notOkMsg: cancelMsg' - ], - outputs: [ - 'ok', - 'notOk: cancel' - ], - template: - '' + - '' - }).Class({ - constructor: function() { - this.ok = new ng.core.EventEmitter(); - this.notOk = new ng.core.EventEmitter(); - }, - onOkClick: function() { - this.ok.next(true); - }, - onNotOkClick: function() { - this.notOk.next(true); - } - }); - // #enddocregion - function AppComponent() { - } - AppComponent.annotations = [ - new ng.core.Component({ - selector: 'hero-io', - template: '' + - '' + - 'OK clicked' + - 'Cancel clicked' - }) - ]; - AppComponent.prototype.onOk = function() { - this.okClicked = true; - } - AppComponent.prototype.onCancel = function() { - this.cancelClicked = true; - } +app.HeroIOComponent = HeroComponent; - app.HeroesIOModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ - AppComponent, - ConfirmComponent - ], - bootstrap: [ AppComponent ] - }) - .Class({ - constructor: function() {} - }); +HeroComponent.annotations = [ + new ng.core.Component({ + selector: 'hero-io', + templateUrl: 'app/hero-io.component.html' + }) +]; + +function HeroComponent() { } + +HeroComponent.prototype.onOk = function() { + this.okClicked = true; +} + +HeroComponent.prototype.onCancel = function() { + this.cancelClicked = true; +} + +})(window.app = window.app || {}); + +///// DSL Version //// + +(function(app) { + +app.HeroIODslComponent = ng.core.Component({ + selector: 'hero-io-dsl', + templateUrl: 'app/hero-io-dsl.component.html' + }) + .Class({ + constructor: function HeroIODslComponent() { }, + onOk: function() { + this.okClicked = true; + }, + onCancel: function() { + this.cancelClicked = true; + } + }); })(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-lifecycle.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-lifecycle.component.js index 3e81c72e4e..94aa3514b2 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero-lifecycle.component.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-lifecycle.component.js @@ -1,29 +1,42 @@ // #docplaster (function(app) { - // #docregion - function HeroComponent() {} - // #enddocregion - HeroComponent.annotations = [ - new ng.core.Component({ - selector: 'hero-lifecycle', - template: '

Hero: {{name}}

' - }) - ]; - // #docregion - HeroComponent.prototype.ngOnInit = - function() { - this.name = 'Windstorm'; - }; - // #enddocregion - app.HeroesLifecycleModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); +// #docregion +app.HeroLifecycleComponent = HeroComponent; + +HeroComponent.annotations = [ + new ng.core.Component({ + selector: 'hero-lifecycle', + template: '

Hero: {{name}}

' + }) +]; + +function HeroComponent() { } + +HeroComponent.prototype.ngOnInit = function() { + // todo: fetch from server async + setTimeout(() => this.name = 'Windstorm', 0); +}; +// #enddocregion + +})(window.app = window.app || {}); + +/////// DSL version //// + +(function(app) { + +// #docregion dsl +app.HeroLifecycleDslComponent = ng.core.Component({ + selector: 'hero-lifecycle-dsl', + template: '

Hero: {{name}}

' + }) + .Class({ + constructor: function HeroLifecycleDslComponent() { }, + ngOnInit: function() { + // todo: fetch from server async + setTimeout(() => this.name = 'Windstorm', 0); + } + }); +// #enddocregion dsl })(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-queries.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-queries.component.js new file mode 100644 index 0000000000..5e21cfcb0b --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-queries.component.js @@ -0,0 +1,92 @@ +(function(app) { + +app.heroQueries = app.heroQueries || {}; + +app.heroQueries.ContentChildComponent = ng.core.Component({ + selector: 'content-child', + template: + '' + + 'Active' + + '' +}).Class({ + constructor: function ContentChildComponent() { + this.active = false; + }, + + activate: function() { + this.active = !this.active; + } +}); + +//////////////////// + +// #docregion content +app.heroQueries.ViewChildComponent = ng.core.Component({ + selector: 'view-child', + template: + '

' + + '{{hero.name}} ' + + '' + + '

', + styles: ['.active {font-weight: bold; background-color: skyblue;}'], + inputs: ['hero'], + queries: { + content: new ng.core.ContentChild(app.heroQueries.ContentChildComponent) + } +}) +.Class({ + constructor: function HeroQueriesHeroComponent() { + this.active = false; + }, + + activate: function() { + this.active = !this.active; + this.content.activate(); + } +}); +// #enddocregion content + +//////////////////// + +// #docregion view +app.heroQueries.HeroQueriesComponent = ng.core.Component({ + selector: 'hero-queries', + template: + '' + + '' + + '' + + '', + queries: { + views: new ng.core.ViewChildren(app.heroQueries.ViewChildComponent) + } +}) +.Class({ + constructor: function HeroQueriesComponent() { + this.active = false; + this.heroData = [ + {id: 1, name: 'Windstorm'}, + {id: 2, name: 'LaughingGas'} + ]; + }, + + activate: function() { + this.active = !this.active; + this.views.forEach(function(view) { + view.activate(); + }); + }, +}); + +// #docregion defined-property +// add prototype property w/ getter outside the DSL +var proto = app.heroQueries.HeroQueriesComponent.prototype; +Object.defineProperty(proto, "buttonLabel", { + get: function () { + return this.active ? 'Deactivate' : 'Activate'; + }, + enumerable: true +}); +// #enddocregion defined-property +// #enddocregion view + +})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.html b/public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.html new file mode 100644 index 0000000000..0e93122d5c --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.html @@ -0,0 +1,4 @@ + +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.js new file mode 100644 index 0000000000..9a8ce7e578 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-title.component.js @@ -0,0 +1,60 @@ +(function(app) { + +// #docregion +app.HeroTitleComponent = HeroTitleComponent; + +// #docregion templateUrl +HeroTitleComponent.annotations = [ + new ng.core.Component({ + selector: 'hero-title', + templateUrl: 'app/hero-title.component.html' + }) +]; +// #enddocregion templateUrl + +function HeroTitleComponent(titlePrefix, title) { + this.titlePrefix = titlePrefix; + this.title = title; + this.msg = ''; +} + +HeroTitleComponent.prototype.ok = function() { + this.msg = 'OK!'; +} + +HeroTitleComponent.parameters = [ + [new ng.core.Optional(), new ng.core.Inject('titlePrefix')], + [new ng.core.Attribute('title')] +]; + +// #enddocregion + +})(window.app = window.app || {}); + +////////// DSL version //////////// + +(function(app) { + +// #docregion dsl +app.HeroTitleDslComponent = ng.core.Component({ + selector: 'hero-title-dsl', + templateUrl: 'app/hero-title.component.html' +}) +.Class({ + constructor: [ + [ new ng.core.Optional(), new ng.core.Inject('titlePrefix') ], + new ng.core.Attribute('title'), + function HeroTitleDslComponent(titlePrefix, title) { + this.titlePrefix = titlePrefix; + this.title = title; + this.msg = ''; + } + ], + + ok: function() { + this.msg = 'OK!'; + } +}); +// #enddocregion dsl + +})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/hero.component.js b/public/docs/_examples/cb-ts-to-js/js/app/hero.component.js index c6a58acc56..346d6f03d8 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/hero.component.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/hero.component.js @@ -1,42 +1,48 @@ // #docplaster -// #docregion appexport (function(app) { - // #enddocregion appexport - // #docregion metadata - // #docregion appexport - // #docregion constructorproto - function HeroComponent() { - this.title = "Hero Detail"; - } - - // #enddocregion constructorproto - // #enddocregion appexport - HeroComponent.annotations = [ - new ng.core.Component({ - selector: 'hero-view', - template: - '

Hero: {{getName()}}

' - }) - ]; - // #docregion constructorproto - HeroComponent.prototype.getName = - function() {return 'Windstorm';}; - // #enddocregion constructorproto - // #enddocregion metadata +// #docregion +// #docregion appexport +// #docregion metadata +app.HeroComponent = HeroComponent; // "export" - app.HeroesModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] - }) - .Class({ - constructor: function() {} - }); +HeroComponent.annotations = [ + new ng.core.Component({ + selector: 'hero-view', + template: '

{{title}}: {{getName()}}

' + }) +]; - // #docregion appexport - app.HeroComponent = HeroComponent; +// #docregion constructorproto +function HeroComponent() { + this.title = "Hero Detail"; +} + +HeroComponent.prototype.getName = function() { return 'Windstorm'; }; +// #enddocregion constructorproto + +// #enddocregion metadata +// #enddocregion appexport +// #enddocregion + +})(window.app = window.app || {}); + +//////////// DSL version /////////// + +(function(app) { + +// #docregion dsl +app.HeroDslComponent = ng.core.Component({ + selector: 'hero-view-dsl', + template: '

{{title}}: {{getName()}}

', + }) + .Class({ + constructor: function HeroDslComponent() { + this.title = "Hero Detail"; + }, + + getName: function() { return 'Windstorm'; } + }); +// #enddocregion dsl })(window.app = window.app || {}); -// #enddocregion appexport diff --git a/public/docs/_examples/cb-ts-to-js/js/app/heroes-bindings.component.js b/public/docs/_examples/cb-ts-to-js/js/app/heroes-bindings.component.js deleted file mode 100644 index 3a562d6912..0000000000 --- a/public/docs/_examples/cb-ts-to-js/js/app/heroes-bindings.component.js +++ /dev/null @@ -1,39 +0,0 @@ -(function(app) { - - // #docregion - var HeroesComponent = ng.core.Component({ - selector: 'heroes-bindings', - template: '

' + - 'Tour of Heroes' + - '

', - host: { - '[title]': 'title', - '[class.heading]': 'hClass', - '(click)': 'clicked()', - '(dblclick)': 'doubleClicked($event)' - } - }).Class({ - constructor: function() { - this.title = 'Tooltip content'; - this.hClass = true; - }, - clicked: function() { - this.active = !this.active; - }, - doubleClicked: function(evt) { - this.active = true; - } - }); - // #enddocregion - - app.HeroesHostBindingsModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ HeroesComponent ], - bootstrap: [ HeroesComponent ] - }) - .Class({ - constructor: function() {} - }); - -})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/heroes-queries.component.js b/public/docs/_examples/cb-ts-to-js/js/app/heroes-queries.component.js deleted file mode 100644 index f1bda77cb1..0000000000 --- a/public/docs/_examples/cb-ts-to-js/js/app/heroes-queries.component.js +++ /dev/null @@ -1,82 +0,0 @@ -(function(app) { - - var ActiveLabelComponent = ng.core.Component({ - selector: 'active-label', - template: '' + - 'Active' + - '' - }).Class({ - constructor: [function() { }], - activate: function() { - this.active = true; - } - }); - - // #docregion content - var HeroComponent = ng.core.Component({ - selector: 'a-hero', - template: '

' + - '{{hero.name}} ' + - '' + - '

', - inputs: ['hero'], - queries: { - label: new ng.core.ContentChild( - ActiveLabelComponent) - } - }).Class({ - constructor: [function() { }], - activate: function() { - this.active = true; - this.label.activate(); - } - }); - app.HeroQueriesComponent = HeroComponent; - // #enddocregion content - - // #docregion view - var AppComponent = ng.core.Component({ - selector: 'heroes-queries', - template: - '' + - '' + - '' + - '', - queries: { - heroCmps: new ng.core.ViewChildren( - HeroComponent) - } - }).Class({ - constructor: function() { - this.heroData = [ - {id: 1, name: 'Windstorm'}, - {id: 2, name: 'Superman'} - ]; - }, - activate: function() { - this.heroCmps.forEach(function(cmp) { - cmp.activate(); - }); - } - }); - // #enddocregion view - - app.HeroesQueriesModule = - ng.core.NgModule({ - imports: [ ng.platformBrowser.BrowserModule ], - declarations: [ - AppComponent, - HeroComponent, - ActiveLabelComponent - ], - bootstrap: [ AppComponent ] - }) - .Class({ - constructor: function() {} - }); - -})(window.app = window.app || {}); diff --git a/public/docs/_examples/cb-ts-to-js/js/app/main.js b/public/docs/_examples/cb-ts-to-js/js/app/main.js index 9091452599..fd3e737c9e 100644 --- a/public/docs/_examples/cb-ts-to-js/js/app/main.js +++ b/public/docs/_examples/cb-ts-to-js/js/app/main.js @@ -1,35 +1,9 @@ -// #docplaster -// #docregion appimport (function(app) { - // #enddocregion appimport - // #docregion ng2import - var platformBrowserDynamic = - ng.platformBrowserDynamic.platformBrowserDynamic; - var LocationStrategy = - ng.common.LocationStrategy; - var HashLocationStrategy = - ng.common.HashLocationStrategy; - // #enddocregion ng2import +var platformBrowserDynamic = ng.platformBrowserDynamic.platformBrowserDynamic; - // #docregion appimport - var HeroComponent = app.HeroComponent; - // #enddocregion appimport +document.addEventListener('DOMContentLoaded', function() { + platformBrowserDynamic().bootstrapModule(app.AppModule); +}); - document.addEventListener('DOMContentLoaded', function() { - platformBrowserDynamic().bootstrapModule(app.HeroesModule); - platformBrowserDynamic().bootstrapModule(app.HeroesDslModule); - platformBrowserDynamic().bootstrapModule(app.HeroesLifecycleModule); - platformBrowserDynamic().bootstrapModule(app.HeroesDIModule); - platformBrowserDynamic().bootstrapModule(app.HeroDIInlineModule); - platformBrowserDynamic().bootstrapModule(app.HeroesDIInjectModule); - platformBrowserDynamic().bootstrapModule(app.HeroesDIInjectModule2); - platformBrowserDynamic().bootstrapModule(app.HeroesDIInjectAdditionalModule); - platformBrowserDynamic().bootstrapModule(app.HeroesIOModule); - platformBrowserDynamic().bootstrapModule(app.HeroesHostBindingsModule); - platformBrowserDynamic().bootstrapModule(app.HeroesQueriesModule); - }); - - // #docregion appimport })(window.app = window.app || {}); -// #enddocregion appimport 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..7d2105bf78 100644 --- a/public/docs/_examples/cb-ts-to-js/js/index.html +++ b/public/docs/_examples/cb-ts-to-js/js/index.html @@ -4,64 +4,41 @@ + TypeScript to JavaScript + - + + + - - - - - + + + + + + - -

TypeScript to JavaScript

- Classes and Class Metadata
- Input and Output Metadata
- Dependency Injection
- Host and Query Metadata
- -
-

Classes and Class Metadata

- Loading hero-view... - Loading hero-view2... - Loading hero-lifecycle... - -
-

Input and Output Metadata

- Loading hero-io... - -
-

Dependency Injection

- Loading hero-di... - Loading hero-di-inline... - Loading hero-di-inline2... - Loading hero-di-inject... - Loading hero-di-inject-additional... - -
-

Host and Query Metadata

- Loading heroes-bindings... - Loading heroes-queries... + Loading... diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/app.component.html b/public/docs/_examples/cb-ts-to-js/ts/app/app.component.html new file mode 100644 index 0000000000..7f1efd31a0 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/app.component.html @@ -0,0 +1,31 @@ + +

{{title}}

+Classes and Class Metadata
+Input and Output Decorators
+Dependency Injection
+Host Metadata
+View and Child Metadata
+ +
+

Classes and Class Metadata

+ + + +
+

Input and Output Metadata

+ + +
+

Dependency Injection

+ + + + +
+

Host Metadata

+ + + +
+

View and Child Metadata

+ diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/app.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/app.component.ts new file mode 100644 index 0000000000..722d812f63 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/app.component.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; + +@Component({ + moduleId: module.id, + selector: 'my-app', + templateUrl: 'app.component.html', + styles: [ + // See hero-di-inject-additional.component + 'hero-host, hero-host-meta { border: 1px dashed black; display: block; padding: 4px;}', + '.heading {font-style: italic}' + ] +}) +export class AppComponent { + title = 'TypeScript'; +} diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/app.module.ts b/public/docs/_examples/cb-ts-to-js/ts/app/app.module.ts new file mode 100644 index 0000000000..8aafe9c9bb --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/app.module.ts @@ -0,0 +1,56 @@ +/* tslint:disable-next-line:no-unused-variable */ +import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; + +import { AppComponent } from './app.component'; +import { ConfirmComponent } from './confirm.component'; +// #docregion appimport +import { HeroComponent } from './hero.component'; +// #enddocregion appimport +import { HeroComponent as HeroDIComponent } from './hero-di.component'; +import { HeroComponent as HeroDIInjectComponent } from './hero-di-inject.component'; +import { HeroComponent as HeroDIInjectAdditionalComponent } from './hero-di-inject-additional.component'; +import { HeroHostComponent } from './hero-host.component'; +import { HeroHostMetaComponent } from './hero-host-meta.component'; +import { HeroIOComponent } from './hero-io.component'; +import { HeroComponent as HeroLifecycleComponent } from './hero-lifecycle.component'; +import { HeroQueriesComponent, ViewChildComponent, ContentChildComponent } from './hero-queries.component'; +import { HeroTitleComponent } from './hero-title.component'; + +import { DataService } from './data.service'; + +@NgModule({ + imports: [ + BrowserModule + ], + declarations: [ + AppComponent, + ConfirmComponent, + HeroComponent, + HeroDIComponent, + HeroDIInjectComponent, + HeroDIInjectAdditionalComponent, + HeroHostComponent, HeroHostMetaComponent, + HeroIOComponent, + HeroLifecycleComponent, + HeroQueriesComponent, ViewChildComponent, ContentChildComponent, + HeroTitleComponent + ], + providers: [ + DataService, + { provide: 'heroName', useValue: 'Windstorm' } + ], + bootstrap: [ AppComponent ], + + // schemas: [ NO_ERRORS_SCHEMA ] // helpful for debugging! +}) +export class AppModule { } + +/* tslint:disable no-unused-variable */ +// #docregion ng2import +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { + LocationStrategy, + HashLocationStrategy +} from '@angular/common'; +// #enddocregion ng2import 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/confirm.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/confirm.component.ts new file mode 100644 index 0000000000..08a0ed6c60 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/confirm.component.ts @@ -0,0 +1,22 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +// #docregion +@Component({ + moduleId: module.id, + selector: 'app-confirm', + templateUrl: 'confirm.component.html' +}) +export class ConfirmComponent { + @Input() okMsg = ''; + @Input('cancelMsg') notOkMsg = ''; + @Output() ok = new EventEmitter(); + @Output('cancel') notOk = new EventEmitter(); + + onOkClick() { + this.ok.emit(true); + } + onNotOkClick() { + this.notOk.emit(true); + } +} +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/data.service.ts b/public/docs/_examples/cb-ts-to-js/ts/app/data.service.ts index 7e9c7456c6..cd7f9e1aae 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/data.service.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/data.service.ts @@ -2,8 +2,8 @@ import { Injectable } from '@angular/core'; @Injectable() export class DataService { - constructor() { - } + constructor() { } + getHeroName() { return 'Windstorm'; } 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 146c6cbd83..ec460a9dbc 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 @@ -1,50 +1,7 @@ -import { - Attribute, - Component, - Inject, - Optional, - NgModule -} from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -// #docregion -@Component({ - selector: 'hero-title', - template: ` -

{{titlePrefix}} {{title}}

- -

{{ msg }}

- ` -}) -class TitleComponent { - private msg: string = ''; - constructor( - @Inject('titlePrefix') - @Optional() - private titlePrefix: string, - @Attribute('title') - private title: string) { - } - - ok() { - this.msg = 'OK!'; - } -} -// #enddocregion +import { Component } from '@angular/core'; @Component({ selector: 'hero-di-inject-additional', - template: ` - ` + template: `` }) -class AppComponent { } - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ - AppComponent, - TitleComponent - ], - bootstrap: [ AppComponent ] -}) -export class HeroesDIInjectAdditionalModule { } +export class HeroComponent { } diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject.component.ts index 7dc2bc84a2..c583a1b0f6 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject.component.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject.component.ts @@ -1,23 +1,11 @@ -import { Component, Inject, NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; +import { Component, Inject } from '@angular/core'; // #docregion @Component({ selector: 'hero-di-inject', template: `

Hero: {{name}}

` }) -class HeroComponent { - constructor( - @Inject('heroName') - private name: string) { - } +export class HeroComponent { + constructor(@Inject('heroName') private name: string) { } } // #enddocregion - -@NgModule({ - imports: [ BrowserModule ], - providers: [ { provide: 'heroName', useValue: 'Windstorm' } ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] -}) -export class HeroesDIInjectModule { } diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-di.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di.component.ts index a20453ef0a..0cc78d277e 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/hero-di.component.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di.component.ts @@ -1,6 +1,4 @@ -import { Component, NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - +import { Component } from '@angular/core'; import { DataService } from './data.service'; // #docregion @@ -8,18 +6,10 @@ import { DataService } from './data.service'; selector: 'hero-di', template: `

Hero: {{name}}

` }) -class HeroComponent { - name: string; +export class HeroComponent { + name = ''; constructor(dataService: DataService) { this.name = dataService.getHeroName(); } } // #enddocregion - -@NgModule({ - imports: [ BrowserModule ], - providers: [ DataService ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] -}) -export class HeroesDIModule { } diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-host-meta.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-host-meta.component.ts new file mode 100644 index 0000000000..fefe4a5470 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-host-meta.component.ts @@ -0,0 +1,44 @@ +import { Component } from '@angular/core'; + +// #docregion +@Component({ + selector: 'hero-host-meta', + template: ` +

Hero Host in Metadata

+
Heading clicks: {{clicks}}
+ `, + host: { + // HostBindings to the element + '[title]': 'title', + '[class.heading]': 'headingClass', + + // HostListeners on the entire element + '(click)': 'clicked()', + '(mouseenter)': 'enter($event)', + '(mouseleave)': 'leave($event)' + }, + // Styles within (but excluding) the element + styles: ['.active {background-color: coral;}'] +}) +export class HeroHostMetaComponent { + title = 'Hero Host in Metadata Tooltip'; + headingClass = true; + + active = false; + clicks = 0; + + clicked() { + this.clicks += 1; + } + + enter(event: Event) { + this.active = true; + this.headingClass = false; + } + + leave(event: Event) { + this.active = false; + this.headingClass = true; + } +} +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-host.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-host.component.ts new file mode 100644 index 0000000000..e8d72233c8 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-host.component.ts @@ -0,0 +1,39 @@ +import { Component, HostBinding, HostListener } from '@angular/core'; + +// #docregion +@Component({ + selector: 'hero-host', + template: ` +

Hero Host in Decorators

+
Heading clicks: {{clicks}}
+ `, + // Styles within (but excluding) the element + styles: ['.active {background-color: yellow;}'] +}) +export class HeroHostComponent { + // HostBindings to the element + @HostBinding() title = 'Hero Host in Decorators Tooltip'; + @HostBinding('class.heading') headingClass = true; + + active = false; + clicks = 0; + + // HostListeners on the entire element + @HostListener('click') + clicked() { + this.clicks += 1; + } + + @HostListener('mouseenter', ['$event']) + enter(event: Event) { + this.active = true; + this.headingClass = false; + } + + @HostListener('mouseleave', ['$event']) + leave(event: Event) { + this.active = false; + this.headingClass = true; + } +} +// #enddocregion 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..4b36411e78 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 @@ -1,73 +1,26 @@ -import { - Component, - EventEmitter, - Input, - Output, - NgModule -} from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -// #docregion -@Component({ - selector: 'my-confirm', - template: ` - - - ` -}) -class ConfirmComponent { - @Input() okMsg: string; - @Input('cancelMsg') notOkMsg: string; - @Output() ok = - new EventEmitter(); - @Output('cancel') notOk = - new EventEmitter(); - - onOkClick() { - this.ok.next(true); - } - onNotOkClick() { - this.notOk.next(true); - } -} -// #enddocregion - +import { Component } from '@angular/core'; @Component({ selector: 'hero-io', template: ` - - + + OK clicked Cancel clicked ` }) -class AppComponent { - okClicked: boolean; - cancelClicked: boolean; +export class HeroIOComponent { + okClicked = false; + cancelClicked = false; onOk() { this.okClicked = true; } + onCancel() { this.cancelClicked = true; } } - - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ - AppComponent, - ConfirmComponent - ], - bootstrap: [ AppComponent ] -}) -export class HeroesIOModule { } diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-lifecycle.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-lifecycle.component.ts index 1181c71cc9..2629c85a1a 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/hero-lifecycle.component.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-lifecycle.component.ts @@ -1,28 +1,14 @@ -// #docplaster // #docregion import { Component, OnInit } from '@angular/core'; -// #enddocregion -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; @Component({ selector: 'hero-lifecycle', template: `

Hero: {{name}}

` }) -// #docregion -class HeroComponent - implements OnInit { +export class HeroComponent implements OnInit { name: string; ngOnInit() { - this.name = 'Windstorm'; + // todo: fetch from server async + setTimeout(() => this.name = 'Windstorm', 0); } } -// #enddocregion - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] -}) -export class HeroesLifecycleModule { } - diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-queries.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-queries.component.ts new file mode 100644 index 0000000000..8b2d91ea85 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-queries.component.ts @@ -0,0 +1,83 @@ +import { + Component, + ContentChild, + Input, + QueryList, + ViewChildren +} from '@angular/core'; + +@Component({ + selector: 'content-child', + template: ` + + Active + ` +}) +export class ContentChildComponent { + active = false; + + activate() { + this.active = !this.active; + } +} + +//////////////////// + +// #docregion content +@Component({ + selector: 'view-child', + template: ` +

+ {{hero.name}} + +

`, + styles: ['.active {font-weight: bold; background-color: skyblue;}'] +}) +export class ViewChildComponent { + @Input() hero: any; + active = false; + + @ContentChild(ContentChildComponent) content: ContentChildComponent; + + activate() { + this.active = !this.active; + this.content.activate(); + } +} +// #enddocregion content + +//////////////////// + +// #docregion view +@Component({ + selector: 'hero-queries', + template: ` + + + + + ` +}) +export class HeroQueriesComponent { + active = false; + heroData = [ + {id: 1, name: 'Windstorm'}, + {id: 2, name: 'LaughingGas'} + ]; + + @ViewChildren(ViewChildComponent) views: QueryList; + + activate() { + this.active = !this.active; + this.views.forEach( + view => view.activate() + ); + } + + // #docregion defined-property + get buttonLabel() { + return this.active ? 'Deactivate' : 'Activate'; + } + // #enddocregion defined-property +} +// #enddocregion view diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.html b/public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.html new file mode 100644 index 0000000000..0e93122d5c --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.html @@ -0,0 +1,4 @@ + +

{{titlePrefix}} {{title}}

+ +

{{ msg }}

diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.ts new file mode 100644 index 0000000000..074f2edd61 --- /dev/null +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-title.component.ts @@ -0,0 +1,22 @@ +import { Attribute, Component, Inject, Optional } from '@angular/core'; + +// #docregion +// #docregion templateUrl +@Component({ + moduleId: module.id, + selector: 'hero-title', + templateUrl: 'hero-title.component.html' +}) +// #enddocregion templateUrl +export class HeroTitleComponent { + msg: string = ''; + constructor( + @Inject('titlePrefix') @Optional() private titlePrefix: string, + @Attribute('title') private title: string + ) { } + + ok() { + this.msg = 'OK!'; + } +} +// #enddocregion diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/hero.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/hero.component.ts index 4b4ba8529d..4ea4c11611 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/hero.component.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero.component.ts @@ -1,30 +1,14 @@ -// #docplaster // #docregion metadata import { Component } from '@angular/core'; @Component({ selector: 'hero-view', - template: - '

Hero: {{getName()}}

' + template: '

{{title}}: {{getName()}}

' }) -// #docregion appexport -// #docregion class +// #docregion appexport, class export class HeroComponent { title = 'Hero Detail'; getName() {return 'Windstorm'; } } -// #enddocregion class -// #enddocregion appexport +// #enddocregion appexport, class // #enddocregion metadata - -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ HeroComponent ], - bootstrap: [ HeroComponent ] -}) -export class HeroesModule { } - - diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/heroes-bindings.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/heroes-bindings.component.ts deleted file mode 100644 index 407b8b0e29..0000000000 --- a/public/docs/_examples/cb-ts-to-js/ts/app/heroes-bindings.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { - Component, - HostBinding, - HostListener, - NgModule -} from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -// #docregion -@Component({ - selector: 'heroes-bindings', - template: `

- Tour of Heroes -

` -}) -class HeroesComponent { - @HostBinding() title = 'Tooltip content'; - @HostBinding('class.heading') - hClass = true; - active: boolean; - - constructor() {} - - @HostListener('click') - clicked() { - this.active = !this.active; - } - - @HostListener('dblclick', ['$event']) - doubleClicked(evt: Event) { - this.active = true; - } -} -// #enddocregion - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ HeroesComponent ], - bootstrap: [ HeroesComponent ] -}) -export class HeroesHostBindingsModule { } diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/heroes-queries.component.ts b/public/docs/_examples/cb-ts-to-js/ts/app/heroes-queries.component.ts deleted file mode 100644 index 97003766e6..0000000000 --- a/public/docs/_examples/cb-ts-to-js/ts/app/heroes-queries.component.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { - Component, - ViewChildren, - ContentChild, - QueryList, - Input, - NgModule -} from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -@Component({ - selector: 'active-label', - template: ` - Active - ` -}) -class ActiveLabelComponent { - active: boolean; - - activate() { - this.active = true; - } -} - -// #docregion content -@Component({ - selector: 'a-hero', - template: `

- {{hero.name}} - -

` -}) -class HeroComponent { - @Input() hero: any; - active: boolean; - - @ContentChild(ActiveLabelComponent) - label: ActiveLabelComponent; - - activate() { - this.active = true; - this.label.activate(); - } -} -// #enddocregion content - - -// #docregion view -@Component({ - selector: 'heroes-queries', - template: ` - - - - - ` -}) -class HeroesQueriesComponent { - heroData = [ - {id: 1, name: 'Windstorm'}, - {id: 2, name: 'Superman'} - ]; - - @ViewChildren(HeroComponent) - heroCmps: QueryList; - - activate() { - this.heroCmps.forEach( - (cmp) => cmp.activate() - ); - } -} -// #enddocregion view - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ - HeroesQueriesComponent, - HeroComponent, - ActiveLabelComponent - ], - bootstrap: [ HeroesQueriesComponent ] -}) -export class HeroesQueriesModule { } diff --git a/public/docs/_examples/cb-ts-to-js/ts/app/main.ts b/public/docs/_examples/cb-ts-to-js/ts/app/main.ts index 92f5af5e1a..7cc80b5964 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/app/main.ts +++ b/public/docs/_examples/cb-ts-to-js/ts/app/main.ts @@ -1,30 +1,4 @@ -/* tslint:disable no-unused-variable */ -// #docregion ng2import -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { - LocationStrategy, - HashLocationStrategy -} from '@angular/common'; -// #enddocregion ng2import - -// #docregion appimport -import { HeroComponent } from './hero.component'; -// #enddocregion appimport - -import { HeroesModule } from './hero.component'; -import { HeroesLifecycleModule } from './hero-lifecycle.component'; -import { HeroesDIModule } from './hero-di.component'; -import { HeroesDIInjectModule } from './hero-di-inject.component'; -import { HeroesDIInjectAdditionalModule } from './hero-di-inject-additional.component'; -import { HeroesIOModule } from './hero-io.component'; -import { HeroesHostBindingsModule } from './heroes-bindings.component'; -import { HeroesQueriesModule } from './heroes-queries.component'; - -platformBrowserDynamic().bootstrapModule(HeroesModule); -platformBrowserDynamic().bootstrapModule(HeroesLifecycleModule); -platformBrowserDynamic().bootstrapModule(HeroesDIModule); -platformBrowserDynamic().bootstrapModule(HeroesDIInjectModule); -platformBrowserDynamic().bootstrapModule(HeroesDIInjectAdditionalModule); -platformBrowserDynamic().bootstrapModule(HeroesIOModule); -platformBrowserDynamic().bootstrapModule(HeroesHostBindingsModule); -platformBrowserDynamic().bootstrapModule(HeroesQueriesModule); +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { AppModule } from './app.module'; + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/public/docs/_examples/cb-ts-to-js/ts/index.html b/public/docs/_examples/cb-ts-to-js/ts/index.html index c635706f38..5791134d4f 100644 --- a/public/docs/_examples/cb-ts-to-js/ts/index.html +++ b/public/docs/_examples/cb-ts-to-js/ts/index.html @@ -5,6 +5,7 @@ + TypeScript to JavaScript @@ -20,32 +21,7 @@ - -

TypeScript to JavaScript

- Classes and Class Metadata
- Input and Output Metadata
- Dependency Injection
- Host and Query Metadata
- -
-

Classes and Class Metadata

- Loading hero-view... - Loading hero-lifecycle... - -
-

Input and Output Metadata

- Loading hero-io... - -
-

Dependency Injection

- Loading hero-di... - Loading hero-di-inject... - Loading hero-di-inject-additional... - -
-

Host and Query Metadata

- Loading heroes-bindings... - Loading heroes-queries... + Loading... diff --git a/public/docs/_examples/ngmodule/ts/index.0.html b/public/docs/_examples/ngmodule/ts/index.0.html index 4ad8c4fc18..1b72565156 100644 --- a/public/docs/_examples/ngmodule/ts/index.0.html +++ b/public/docs/_examples/ngmodule/ts/index.0.html @@ -13,7 +13,7 @@ - + - + - + - + - + Syntax'; // #enddocregion evil-title @@ -180,6 +178,21 @@ export class AppComponent implements AfterViewInit, OnInit { } // #enddocregion setStyles + // #docregion NgStyle + isItalic = false; + isBold = false; + fontSize: string = 'large'; + fontSizePx: number | string = 14; + + setStyle() { + return { + 'font-style': this.isItalic ? 'italic' : 'normal', + 'font-weight': this.isBold ? 'bold' : 'normal', + 'font-size': this.fontSize + }; + } + // #enddocregion NgStyle + toeChoice = ''; toeChooser(picker: HTMLFieldSetElement) { let choices = picker.children; diff --git a/public/docs/_examples/template-syntax/ts/app/app.module.ts b/public/docs/_examples/template-syntax/ts/app/app.module.ts index db940fad08..712b613daf 100644 --- a/public/docs/_examples/template-syntax/ts/app/app.module.ts +++ b/public/docs/_examples/template-syntax/ts/app/app.module.ts @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { BigHeroDetailComponent, HeroDetailComponent } from './hero-detail.component'; -import { MyClickDirective, MyClickDirective2 } from './my-click.directive'; +import { ClickDirective, ClickDirective2 } from './click.directive'; import { SizerComponent } from './sizer.component'; @NgModule({ @@ -16,8 +16,8 @@ import { SizerComponent } from './sizer.component'; AppComponent, BigHeroDetailComponent, HeroDetailComponent, - MyClickDirective, - MyClickDirective2, + ClickDirective, + ClickDirective2, SizerComponent ], bootstrap: [ AppComponent ] diff --git a/public/docs/_examples/template-syntax/ts/app/my-click.directive.ts b/public/docs/_examples/template-syntax/ts/app/click.directive.ts similarity index 76% rename from public/docs/_examples/template-syntax/ts/app/my-click.directive.ts rename to public/docs/_examples/template-syntax/ts/app/click.directive.ts index 1f552277bf..09757bfeaf 100644 --- a/public/docs/_examples/template-syntax/ts/app/my-click.directive.ts +++ b/public/docs/_examples/template-syntax/ts/app/click.directive.ts @@ -3,10 +3,10 @@ import { Directive, ElementRef, EventEmitter, Output } from '@angular/core'; @Directive({selector: '[myClick]'}) -export class MyClickDirective { - // #docregion my-click-output-1 +export class ClickDirective { + // #docregion output-myClick @Output('myClick') clicks = new EventEmitter(); // @Output(alias) propertyName = ... - // #enddocregion my-click-output-1 + // #enddocregion output-myClick toggle = false; @@ -19,15 +19,15 @@ export class MyClickDirective { } } -// #docregion my-click-output-2 +// #docregion output-myClick2 @Directive({ -// #enddocregion my-click-output-2 + // #enddocregion output-myClick2 selector: '[myClick2]', -// #docregion my-click-output-2 + // #docregion output-myClick2 outputs: ['clicks:myClick'] // propertyName:alias }) -// #enddocregion my-click-output-2 -export class MyClickDirective2 { +// #enddocregion output-myClick2 +export class ClickDirective2 { clicks = new EventEmitter(); toggle = false; diff --git a/public/docs/_examples/template-syntax/ts/app/sizer.component.ts b/public/docs/_examples/template-syntax/ts/app/sizer.component.ts index cf0ef4af47..b6065c8cd1 100644 --- a/public/docs/_examples/template-syntax/ts/app/sizer.component.ts +++ b/public/docs/_examples/template-syntax/ts/app/sizer.component.ts @@ -11,15 +11,14 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; ` }) export class SizerComponent { - @Input() size: number; + @Input() size: number | string; @Output() sizeChange = new EventEmitter(); dec() { this.resize(-1); } inc() { this.resize(+1); } resize(delta: number) { - const size = +this.size + delta; - this.size = Math.min(40, Math.max(8, size)); + this.size = Math.min(40, Math.max(8, +this.size + delta)); this.sizeChange.emit(this.size); } } diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart b/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart index bc2293cec1..1731bf4d0e 100644 --- a/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart @@ -4,21 +4,27 @@ import 'dart:async'; import 'package:angular2/core.dart'; +// #docregion import-router +import 'package:angular2/router.dart'; +// #enddocregion import-router import 'hero.dart'; import 'hero_service.dart'; // #enddocregion imports +// #docregion metadata @Component( selector: 'my-dashboard', // #docregion templateUrl templateUrl: 'dashboard_component.html', // #enddocregion templateUrl // #docregion css - styleUrls: const ['dashboard_component.css'] + styleUrls: const ['dashboard_component.css'], // #enddocregion css + directives: const [ROUTER_DIRECTIVES], ) -// #docregion component +// #enddocregion metadata +// #docregion class, component class DashboardComponent implements OnInit { List heroes; @@ -26,11 +32,9 @@ class DashboardComponent implements OnInit { final HeroService _heroService; DashboardComponent(this._heroService); - // #enddocregion ctor Future ngOnInit() async { heroes = (await _heroService.getHeroes()).skip(1).take(4).toList(); } } -// #enddocregion component diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.html b/public/docs/_examples/toh-5/dart/lib/dashboard_component.html index 49e77c460c..f48c102949 100644 --- a/public/docs/_examples/toh-5/dart/lib/dashboard_component.html +++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.html @@ -2,7 +2,7 @@

Top Heroes

- +

{{hero.name}}

diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.1.html b/public/docs/_examples/toh-5/dart/lib/dashboard_component_1.html similarity index 100% rename from public/docs/_examples/toh-5/dart/lib/dashboard_component.1.html rename to public/docs/_examples/toh-5/dart/lib/dashboard_component_1.html diff --git a/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart b/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart index a99528cbaa..df03c092f3 100644 --- a/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart @@ -2,12 +2,12 @@ // #docregion , v2 // #docregion added-imports import 'dart:async'; -import 'dart:html' show window; // #enddocregion added-imports import 'package:angular2/core.dart'; // #docregion added-imports import 'package:angular2/router.dart'; +import 'package:angular2/platform/common.dart'; // #enddocregion added-imports import 'hero.dart'; @@ -17,9 +17,9 @@ import 'hero_service.dart'; @Component( selector: 'my-hero-detail', - // #docregion templateUrl + // #docregion metadata, templateUrl templateUrl: 'hero_detail_component.html', - // #enddocregion templateUrl, v2 + // #enddocregion metadata, templateUrl, v2 styleUrls: const ['hero_detail_component.css'] // #docregion v2 ) @@ -30,8 +30,9 @@ class HeroDetailComponent implements OnInit { // #docregion ctor final HeroService _heroService; final RouteParams _routeParams; + final Location _location; - HeroDetailComponent(this._heroService, this._routeParams); + HeroDetailComponent(this._heroService, this._routeParams, this._location); // #enddocregion ctor // #docregion ngOnInit @@ -44,7 +45,7 @@ class HeroDetailComponent implements OnInit { // #docregion goBack void goBack() { - window.history.back(); + _location.back(); } // #enddocregion goBack } diff --git a/public/docs/_examples/toh-5/dart/lib/heroes_component.dart b/public/docs/_examples/toh-5/dart/lib/heroes_component.dart index e19c3ab3be..2e0eddd076 100644 --- a/public/docs/_examples/toh-5/dart/lib/heroes_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/heroes_component.dart @@ -41,9 +41,11 @@ class HeroesComponent implements OnInit { selectedHero = hero; } + // #docregion gotoDetail Future gotoDetail() => _router.navigate([ 'HeroDetail', {'id': selectedHero.id.toString()} ]); + // #enddocregion gotoDetail // #docregion renaming } diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.1.ts b/public/docs/_examples/toh-5/ts/app/dashboard.component.1.ts index 430a30ebbe..3c92b205c8 100644 --- a/public/docs/_examples/toh-5/ts/app/dashboard.component.1.ts +++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.1.ts @@ -6,4 +6,3 @@ import { Component } from '@angular/core'; template: '

My Dashboard

' }) export class DashboardComponent { } - diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.ts b/public/docs/_examples/toh-5/ts/app/dashboard.component.ts index cb5cfc5b82..9311a74395 100644 --- a/public/docs/_examples/toh-5/ts/app/dashboard.component.ts +++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.ts @@ -33,4 +33,3 @@ export class DashboardComponent implements OnInit { .then(heroes => this.heroes = heroes.slice(1, 5)); } } -// #enddocregion class diff --git a/public/docs/_examples/toh-5/ts/app/hero-detail.component.html b/public/docs/_examples/toh-5/ts/app/hero-detail.component.html index cf96fc2169..8f2ff9d90c 100644 --- a/public/docs/_examples/toh-5/ts/app/hero-detail.component.html +++ b/public/docs/_examples/toh-5/ts/app/hero-detail.component.html @@ -11,4 +11,4 @@ -
\ No newline at end of file +
diff --git a/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts b/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts index 3ca01d2361..3557aa31d5 100644 --- a/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts @@ -1,5 +1,7 @@ // #docplaster -// #docregion , v2 +// #docregion , v2, rxjs-import +import 'rxjs/add/operator/switchMap'; +// #enddocregion rxjs-import import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Params } from '@angular/router'; import { Location } from '@angular/common'; @@ -31,11 +33,9 @@ export class HeroDetailComponent implements OnInit { // #docregion ngOnInit ngOnInit(): void { - this.route.params.forEach((params: Params) => { - let id = +params['id']; - this.heroService.getHero(id) - .then(hero => this.hero = hero); - }); + this.route.params + .switchMap((params: Params) => this.heroService.getHero(+params['id'])) + .subscribe(hero => this.hero = hero); } // #enddocregion ngOnInit diff --git a/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts b/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts index 001b34baf7..a0342415f2 100644 --- a/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts @@ -1,4 +1,5 @@ // #docregion +import 'rxjs/add/operator/switchMap'; import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Params } from '@angular/router'; import { Location } from '@angular/common'; @@ -22,11 +23,9 @@ export class HeroDetailComponent implements OnInit { ) {} ngOnInit(): void { - this.route.params.forEach((params: Params) => { - let id = +params['id']; - this.heroService.getHero(id) - .then(hero => this.hero = hero); - }); + this.route.params + .switchMap((params: Params) => this.heroService.getHero(+params['id'])) + .subscribe(hero => this.hero = hero); } // #docregion save diff --git a/public/docs/_examples/toh-6/ts/app/main.ts b/public/docs/_examples/toh-6/ts/app/main.ts index 091a7d82a7..961a226688 100644 --- a/public/docs/_examples/toh-6/ts/app/main.ts +++ b/public/docs/_examples/toh-6/ts/app/main.ts @@ -1,6 +1,6 @@ // #docregion -// main entry point import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + import { AppModule } from './app.module'; platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/public/docs/_examples/webpack/ts/package.webpack.json b/public/docs/_examples/webpack/ts/package.webpack.json index ed36c0f33f..553ca9338a 100644 --- a/public/docs/_examples/webpack/ts/package.webpack.json +++ b/public/docs/_examples/webpack/ts/package.webpack.json @@ -14,14 +14,14 @@ } ], "dependencies": { - "@angular/common": "~2.1.1", - "@angular/compiler": "~2.1.1", - "@angular/core": "~2.1.1", - "@angular/forms": "~2.1.1", - "@angular/http": "~2.1.1", - "@angular/platform-browser": "~2.1.1", - "@angular/platform-browser-dynamic": "~2.1.1", - "@angular/router": "~3.1.1", + "@angular/common": "~2.2.0", + "@angular/compiler": "~2.2.0", + "@angular/core": "~2.2.0", + "@angular/forms": "~2.2.0", + "@angular/http": "~2.2.0", + "@angular/platform-browser": "~2.2.0", + "@angular/platform-browser-dynamic": "~2.2.0", + "@angular/router": "~3.2.0", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "zone.js": "^0.6.25" diff --git a/public/docs/dart/latest/cookbook/_data.json b/public/docs/dart/latest/cookbook/_data.json index a747acd83f..eb1a46ace4 100644 --- a/public/docs/dart/latest/cookbook/_data.json +++ b/public/docs/dart/latest/cookbook/_data.json @@ -60,7 +60,7 @@ "ts-to-js": { "title": "TypeScript to JavaScript", - "intro": "Convert Angular TypeScript examples into ES5 JavaScript", + "intro": "Convert Angular TypeScript examples into ES6 and ES5 JavaScript", "hide": true }, diff --git a/public/docs/dart/latest/guide/forms.jade b/public/docs/dart/latest/guide/forms.jade index f122411f16..a2d1feb8fa 100644 --- a/public/docs/dart/latest/guide/forms.jade +++ b/public/docs/dart/latest/guide/forms.jade @@ -96,12 +96,6 @@ figure.image-display +makeTabs('forms/dart/pubspec.yaml, forms/dart/web/index.html, forms/dart/web/main.dart', ',initial,', 'pubspec.yaml, web/index.html, web/main.dart') -.l-sub-section - :marked - Note the `platform_directives` entry in `pubspec.yaml`. - It imports core directives and, more importantly for this chapter, - **form directives**. - :marked So that the code can run, let's create a stub for the `` component. diff --git a/public/docs/dart/latest/guide/glossary.jade b/public/docs/dart/latest/guide/glossary.jade index 1d2eb49664..ff49e787f0 100644 --- a/public/docs/dart/latest/guide/glossary.jade +++ b/public/docs/dart/latest/guide/glossary.jade @@ -1,4 +1,4 @@ extends ../glossary -block var-def +block includes include ../_util-fns diff --git a/public/docs/dart/latest/guide/template-syntax.jade b/public/docs/dart/latest/guide/template-syntax.jade index bee8fc97a7..fe62bd9084 100644 --- a/public/docs/dart/latest/guide/template-syntax.jade +++ b/public/docs/dart/latest/guide/template-syntax.jade @@ -48,16 +48,6 @@ block dart-type-exception-example In checked mode, the code above will result in a type exception: `String` isn't a subtype of `Hero`. -block dart-class-binding-bug - .callout.is-helpful - header Angular Issue #6901 - :marked - Issue [#6901][6901] prevents us from using `[class]`. As is illustrated - above, in the meantime we can achieve the same effect by binding to - `className`. - - [6901]: http://github.com/angular/angular/issues/6901 - block style-property-name-dart-diff .callout.is-helpful header Dart difference: Style property names diff --git a/public/docs/dart/latest/tutorial/toh-pt1.jade b/public/docs/dart/latest/tutorial/toh-pt1.jade index 218d35c788..9bdb15fa08 100644 --- a/public/docs/dart/latest/tutorial/toh-pt1.jade +++ b/public/docs/dart/latest/tutorial/toh-pt1.jade @@ -1,8 +1,6 @@ include ../_util-fns :marked - # Once Upon a Time - Every story starts somewhere. Our story starts where the [QuickStart](../quickstart.html) ends. :marked diff --git a/public/docs/dart/latest/tutorial/toh-pt2.jade b/public/docs/dart/latest/tutorial/toh-pt2.jade index 24e38e31b3..e5c78afdec 100644 --- a/public/docs/dart/latest/tutorial/toh-pt2.jade +++ b/public/docs/dart/latest/tutorial/toh-pt2.jade @@ -1,7 +1,6 @@ include ../_util-fns :marked - # It Takes Many Heroes Our story needs more heroes. We’ll expand our Tour of Heroes app to display a list of heroes, allow the user to select a hero, and display the hero’s details. diff --git a/public/docs/dart/latest/tutorial/toh-pt4.jade b/public/docs/dart/latest/tutorial/toh-pt4.jade index cc417c159e..a9d5ca86e2 100644 --- a/public/docs/dart/latest/tutorial/toh-pt4.jade +++ b/public/docs/dart/latest/tutorial/toh-pt4.jade @@ -1,7 +1,6 @@ include ../_util-fns :marked - # Services The Tour of Heroes is evolving and we anticipate adding more components in the near future. Multiple components will need access to hero data and we don't want to copy and diff --git a/public/docs/dart/latest/tutorial/toh-pt5.jade b/public/docs/dart/latest/tutorial/toh-pt5.jade index 6be571c148..9ce3e7ed7b 100644 --- a/public/docs/dart/latest/tutorial/toh-pt5.jade +++ b/public/docs/dart/latest/tutorial/toh-pt5.jade @@ -96,12 +96,13 @@ block redirect-vs-use-as-default router will display the dashboard when the browser URL doesn't match an existing route. block templateUrl-path-resolution - :marked - The value of `templateUrl` can be an [asset][] in this package or another - package. To use an asset in another package, use a full package reference, - such as `'package:some_other_package/dashboard_component.html'`. + .l-sub-section + :marked + The value of `templateUrl` can be an [asset][] in this package or another + package. To use an asset in another package, use a full package reference, + such as `'package:some_other_package/dashboard_component.html'`. - [asset]: https://www.dartlang.org/tools/pub/glossary#asset + [asset]: https://www.dartlang.org/tools/pub/glossary#asset block route-params :marked diff --git a/public/docs/js/latest/_data.json b/public/docs/js/latest/_data.json index d3fff22a9c..18ed3ed0bd 100644 --- a/public/docs/js/latest/_data.json +++ b/public/docs/js/latest/_data.json @@ -4,7 +4,7 @@ "title": "Angular Docs", "subtitle": "JavaScript", "menuTitle": "Docs Home", - "banner": "Angular release is 2.1. View the change log to see enhancements, fixes, and breaking changes." + "banner": "The latest Angular release is 2.2. View the change log to see enhancements, fixes, and breaking changes." }, "quickstart": { diff --git a/public/docs/js/latest/cookbook/_data.json b/public/docs/js/latest/cookbook/_data.json index 3f319736d6..74ee2a0be9 100644 --- a/public/docs/js/latest/cookbook/_data.json +++ b/public/docs/js/latest/cookbook/_data.json @@ -55,7 +55,7 @@ "ts-to-js": { "title": "TypeScript to JavaScript", - "intro": "Convert Angular TypeScript examples into ES5 JavaScript" + "intro": "Convert Angular TypeScript examples into ES6 and ES5 JavaScript" }, "visual-studio-2015": { diff --git a/public/docs/js/latest/cookbook/ts-to-js.jade b/public/docs/js/latest/cookbook/ts-to-js.jade index a76d90bce7..77e3f9b7d6 100644 --- a/public/docs/js/latest/cookbook/ts-to-js.jade +++ b/public/docs/js/latest/cookbook/ts-to-js.jade @@ -1,469 +1 @@ -include ../../../../_includes/_util-fns - -:marked - Everything that we can do in Angular in TypeScript, we can also do - in JavaScript. Translating from one language to the other is mostly a - matter of changing the way we organize our code and the way we access - Angular APIs. - - Since TypeScript is a popular language option in Angular, many of the - code examples you see on the Internet as well as on this site are written - in TypeScript. This cookbook contains recipes for translating these kinds of - code examples to ES5, so that they can be applied to Angular JavaScript - applications. - - -:marked - ## Table of contents - - [Modularity: imports and exports](#modularity) - - [Classes and Class Metadata](#class-metadata) - - [Input and Output Metadata](#property-metadata) - - [Dependency Injection](#dependency-injection) - - [Host and Query Metadata](#other-property-metadata) - - **Run and compare the live TypeScript and JavaScript - code shown in this cookbook.** - -a(id="modularity") -.l-main-section -:marked - ## Importing and Exporting - -- var top="vertical-align:top" -table(width="100%") - col(width="50%") - col(width="50%") - tr - th TypeScript - th ES5 JavaScript - tr(style=top) - td - :marked - ### Importing Angular Code - - In TypeScript code, Angular classes, functions, and other members - are imported with TypeScript `import` statements: - - +makeExample('cb-ts-to-js/ts/app/main.ts', 'ng2import')(format="." ) - - td - :marked - ### Accessing Angular Code through the ng global - - In JavaScript code, when using - [the Angular packages](../glossary.html#!#scoped-package), - we can access Angular code through the global `ng` object. In the - nested members of this object we'll find everything we would import - from `@angular` in TypeScript: - - +makeExample('cb-ts-to-js/js/app/main.js', 'ng2import')(format="." ) - - tr(style=top) - td - :marked - ### Importing and Exporting Application Code - - Each file in an Angular TypeScript application constitutes a - TypeScript module. When we want to make something from a module available - to other modules, we `export` it. - - +makeExample('cb-ts-to-js/ts/app/hero.component.ts', 'appexport')(format="." ) - - :marked - In other modules we can then `import` things that have been exported - elsewhere. - - +makeExample('cb-ts-to-js/ts/app/main.ts', 'appimport')(format="." ) - - td - :marked - ### Sharing Application Code - - In an Angular JavaScript application, we load each file to the page - using a `' - html += '' + html += ''; html += ''; return html; } @@ -166,8 +172,8 @@ class PlunkerBuilder { return postData; } - _createPlunkerHtml(postData) { - var baseHtml = this._createBasePlunkerHtml(this.options.embedded); + _createPlunkerHtml(config, postData) { + var baseHtml = this._createBasePlunkerHtml(config, this.options.embedded); var doc = jsdom.jsdom(baseHtml); var form = doc.querySelector('form'); _.forEach(postData, (value, key) => { diff --git a/tools/plunker-builder/indexHtmlTranslator.js b/tools/plunker-builder/indexHtmlTranslator.js index 7f394e09a8..6241bc436f 100644 --- a/tools/plunker-builder/indexHtmlTranslator.js +++ b/tools/plunker-builder/indexHtmlTranslator.js @@ -28,7 +28,7 @@ var _rxRules = { // System.import('app').catch(function(err){ console.error(err); }); // system_strip_import_app: { - from: /