diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000..bab156b63a
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,24 @@
+# http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+
+[*.md]
+max_line_length = 0
+trim_trailing_whitespace = false
+
+[*.jade]
+max_line_length = 0
+trim_trailing_whitespace = false
+
+# Indentation override
+#[lib/**.js]
+#[{package.json,.travis.yml}]
+#[**/**.js]
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index bede42df52..0000000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,11 +0,0 @@
-// Place your settings in this file to overwrite default and user settings.
-{
- // Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened.
- "editor.tabSize": 2,
- // Controls if the editor will insert spaces for tabs. Accepted values: "auto", true, false. If set to "auto", the value will be guessed when a file is opened.
- "editor.insertSpaces": true,
- // When enabled, will trim trailing whitespace when you save a file.
- "files.trimTrailingWhitespace": false,
- // Specifies the folder path containing the tsserver and lib*.d.ts files to use.
- "typescript.tsdk": "public/docs/_examples/node_modules/typescript/lib"
-}
diff --git a/gulpfile.js b/gulpfile.js
index a005d1c5b8..44baa44792 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -69,12 +69,14 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
});
var _exampleBoilerplateFiles = [
- 'karma.conf.js',
- 'karma-test-shim.js',
- 'package.json',
- 'styles.css',
- 'tsconfig.json',
- 'typings.json'
+ '.editorconfig',
+ 'karma.conf.js',
+ 'karma-test-shim.js',
+ 'package.json',
+ 'styles.css',
+ 'tsconfig.json',
+ 'tslint.json',
+ 'typings.json'
];
var _exampleDartWebBoilerPlateFiles = ['styles.css'];
@@ -153,14 +155,17 @@ function findAndRunE2eTests(filter) {
// to the outputFile.
function runE2eTests(appDir, protractorConfigFilename, outputFile ) {
// start the app
- var appRunSpawnInfo = spawnExt('npm',['run','http-server', '--', '-s' ], { cwd: appDir });
-
- // start protractor
- var pcFilename = path.resolve(protractorConfigFilename); // need to resolve because we are going to be running from a different dir
- var exePath = path.join(process.cwd(), "./node_modules/.bin/");
- var spawnInfo = spawnExt('protractor',
- [ pcFilename, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: exePath });
- return spawnInfo.promise.then(function(data) {
+ var appRunSpawnInfo = spawnExt('npm',['run','http-server:e2e', '--', '-s' ], { cwd: appDir });
+ var tscRunSpawnInfo = spawnExt('npm',['run','tsc'], { cwd: appDir });
+
+ return tscRunSpawnInfo.promise.then(function(data) {
+ // start protractor
+ var pcFilename = path.resolve(protractorConfigFilename); // need to resolve because we are going to be running from a different dir
+ var exePath = path.join(process.cwd(), "./node_modules/.bin/");
+ var spawnInfo = spawnExt('protractor',
+ [ pcFilename, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: exePath });
+ return spawnInfo.promise;
+ }).then(function(data) {
// kill the app now that protractor has completed.
// Ugh... proc.kill does not work properly on windows with child processes.
// appRun.proc.kill();
@@ -243,14 +248,14 @@ gulp.task('add-example-boilerplate', function() {
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
fsUtils.addSymlink(realPath, linkPath);
});
-
+
realPath = path.join(EXAMPLES_PATH, '/typings');
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
typingsPaths.forEach(function(linkPath) {
- gutil.log("symlinking " + linkPath + ' -> ' + realPath)
+ gutil.log("symlinking " + linkPath + ' -> ' + realPath)
fsUtils.addSymlink(realPath, linkPath);
});
-
+
return copyExampleBoilerplate();
});
@@ -263,7 +268,7 @@ function copyExampleBoilerplate() {
return path.join(EXAMPLES_PATH, fn);
});
var examplePaths = getExamplePaths(EXAMPLES_PATH);
-
+
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){
return path.join(EXAMPLES_PATH, fn);
});
@@ -287,15 +292,15 @@ gulp.task('remove-example-boilerplate', function() {
nodeModulesPaths.forEach(function(linkPath) {
fsUtils.removeSymlink(linkPath);
});
-
+
var typingsPaths = getTypingsPaths(EXAMPLES_PATH);
typingsPaths.forEach(function(linkPath) {
fsUtils.removeSymlink(linkPath);
- });
-
+ });
+
var examplePaths = getExamplePaths(EXAMPLES_PATH);
var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH);
-
+
return deleteFiles(_exampleBoilerplateFiles, examplePaths)
.then(function() {
return deleteFiles(_exampleDartWebBoilerPlateFiles, dartExampleWebPaths);
@@ -346,7 +351,7 @@ gulp.task('build-js-api-docs', ['_shred-api-examples'], function() {
});
gulp.task('build-plunkers', function() {
- return copyExampleBoilerplate()
+ return copyExampleBoilerplate()
.then(function() {
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log });
});
@@ -501,7 +506,7 @@ function harpCompile() {
vars: { NODE_ENV: "production" }
});
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
-
+
var deferred = Q.defer();
gutil.log('running harp compile...');
showHideExampleNodeModules('hide');
@@ -523,20 +528,20 @@ function harpCompile() {
}
function linkChecker(options) {
- var deferred = Q.defer();
+ var deferred = Q.defer();
var options = options || {};
-
+
var blcOptions = options.blcOptions || {};
var customData = options.customData || {};
-
+
var excludeBad; // don't bother reporting bad links matching this RegExp
if (argv.excludeBad) {
excludeBad = new RegExp(argv.excludeBad);
} else {
excludeBad = options.excludeBad === undefined ? /docs\/dart\/latest\/api/ : '';
}
-
- var previousPage;
+
+ var previousPage;
var siteUrl = argv.url || options.url || 'https://angular.io/';
// See https://github.com/stevenvachon/broken-link-checker#blcsitecheckeroptions-handlers
@@ -546,12 +551,12 @@ function linkChecker(options) {
//gutil.log('Scanning ' + pageUrl);docs/ts/latest/api/core/
},
junk: function(result, customData){},
-
+
// Analyze links
link: function(result, customData){
if (!result.broken) { return; }
if (excludeBad && excludeBad.test(result.url.resolved)) { return; }
-
+
var currentPage = result.base.resolved
if (previousPage !== currentPage) {
previousPage = currentPage;
@@ -563,10 +568,10 @@ function linkChecker(options) {
//gutil.log(msg);
//gutil.log(result);
},
-
+
page: function(error, pageUrl, customData){},
site: function(error, siteUrl, customData){},
-
+
end: function(){
var stopTime = new Date().getTime();
var elapsed = 'Elapsed link-checking time: ' + ((stopTime - startTime)/1000) + ' seconds';
@@ -576,24 +581,24 @@ function linkChecker(options) {
deferred.resolve(true);
}
};
-
+
// create an output file with header.
var outputFile = path.join(process.cwd(), 'link-checker-results.txt');
var header = 'Link checker results for: ' + siteUrl +
- '\nStarted: ' + (new Date()).toLocaleString() +
+ '\nStarted: ' + (new Date()).toLocaleString() +
'\nSkipping bad links matching regex: ' +excludeBad.toString() + '\n\n';
gutil.log(header);
fs.writeFileSync(outputFile, header);
-
+
var siteChecker = new blc.SiteChecker(blcOptions, handlers);
var startTime = new Date().getTime();
-
- try {
+
+ try {
siteChecker.enqueue(siteUrl, customData);
} catch (err) {
deferred.reject(err);
- }
- return deferred.promise;
+ }
+ return deferred.promise;
}
// harp has issues with node_modules under the public dir
@@ -701,7 +706,7 @@ function watchAndSync(options, cb) {
env({
vars: { NODE_ENV: "production" }
});
-
+
execCommands(['npm run harp -- server .'], {}, cb);
var browserSync = require('browser-sync').create();
@@ -781,7 +786,7 @@ function apiExamplesWatch(postShredAction) {
function devGuideExamplesWatch(shredOptions, postShredAction) {
var includePattern = path.join(shredOptions.examplesDir, '**/*.*');
- // removed this version because gulp.watch has the same glob issue that dgeni has.
+ // removed this version because gulp.watch has the same glob issue that dgeni has.
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_fragments/**']});
@@ -989,7 +994,7 @@ function execCommands(cmds, options, cb) {
if (!cmds || cmds.length == 0) cb(null, null, null);
var exec = require('child_process').exec; // just to make it more portable.
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
-
+
exec(cmds[0], options, function(err, stdout, stderr) {
if (err == null) {
if (options.shouldLog) {
@@ -1019,4 +1024,3 @@ function checkAngularProjectPath() {
throw new Error('API related tasks require the angular2 repo to be at ' + path.resolve(ANGULAR_PROJECT_PATH));
}
}
-
diff --git a/harp.json b/harp.json
index ea7c3b3a2a..be714f031d 100644
--- a/harp.json
+++ b/harp.json
@@ -47,6 +47,8 @@
"juleskremer": {
"name": "Jules Kremer",
"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.",
"type": "Lead"
},
@@ -397,6 +399,14 @@
"website": "http://teropa.info/",
"bio": "Tero is an independent software developer and writer. He's been building web applications for his whole professional career, and has almost figured out how to do vertical centering in CSS.",
"type": "Community"
+ },
+ "deborah": {
+ "name": "Deborah Kurata",
+ "picture": "/resources/images/bios/deborah.jpg",
+ "twitter": "deborahkurata",
+ "website": "http://blogs.msmvps.com/deborahk/",
+ "bio": "Deborah is an independent software developer and author. She is author of several Pluralsight courses including: 'Angular 2: Getting Started'",
+ "type": "Community"
}
}
}
diff --git a/package.json b/package.json
index ece8163872..e8267dcdec 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"gulp-task-listing": "^1.0.1",
"gulp-util": "^3.0.6",
"gulp-watch": "^4.3.4",
- "harp": "^0.20.1",
+ "harp": "^0.20.3",
"html2jade": "^0.8.4",
"indent-string": "^2.1.0",
"jasmine-core": "^2.3.4",
@@ -71,5 +71,6 @@
},
"dependencies": {
"jstransformer-marked": "^1.0.1"
- }
+ },
+ "homepage": "http://angular.io/"
}
diff --git a/public/_includes/_footer.jade b/public/_includes/_footer.jade
index 394072d8ed..2fd238dc06 100644
--- a/public/_includes/_footer.jade
+++ b/public/_includes/_footer.jade
@@ -19,7 +19,6 @@ else
ul.text-body
li Angular 2.0
li Angular 1 for JS
- li Angular 1 for Dart
li Angular Material
li AngularFire
@@ -54,4 +53,4 @@ else
footer(class="background-steel")
small.text-caption Powered by Google ©2010-2016. Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
a(aria-label="View Style Guide" href=styleguide title="Style Guide" class="styleguide-trigger text-snow" md-button)
- span.icon-favorite
\ No newline at end of file
+ span.icon-favorite
diff --git a/public/docs/_examples/.editorconfig b/public/docs/_examples/.editorconfig
new file mode 100644
index 0000000000..f2abacf6d3
--- /dev/null
+++ b/public/docs/_examples/.editorconfig
@@ -0,0 +1,20 @@
+# http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+
+[*.md]
+max_line_length = 0
+trim_trailing_whitespace = false
+
+# Indentation override
+#[lib/**.js]
+#[{package.json,.travis.yml}]
+#[**/**.js]
diff --git a/public/docs/_examples/.gitignore b/public/docs/_examples/.gitignore
index 7a15251d4f..d821c82bea 100644
--- a/public/docs/_examples/.gitignore
+++ b/public/docs/_examples/.gitignore
@@ -1,3 +1,4 @@
+.editorconfig
styles.css
typings
typings.json
@@ -6,5 +7,6 @@ package.json
karma.conf.js
karma-test-shim.js
tsconfig.json
+tslint.json
npm-debug*.
**/protractor.config.js
diff --git a/public/docs/_examples/architecture/dart/lib/backend_service.dart b/public/docs/_examples/architecture/dart/lib/backend_service.dart
index ed425dfc82..d0f6886dbf 100644
--- a/public/docs/_examples/architecture/dart/lib/backend_service.dart
+++ b/public/docs/_examples/architecture/dart/lib/backend_service.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
import 'logger_service.dart';
diff --git a/public/docs/_examples/architecture/dart/lib/hero_detail_component.dart b/public/docs/_examples/architecture/dart/lib/hero_detail_component.dart
index d89b4e44a8..94c26abbd0 100644
--- a/public/docs/_examples/architecture/dart/lib/hero_detail_component.dart
+++ b/public/docs/_examples/architecture/dart/lib/hero_detail_component.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/architecture/dart/lib/hero_list_component.dart b/public/docs/_examples/architecture/dart/lib/hero_list_component.dart
index 7027a01bd8..ba2b75de70 100644
--- a/public/docs/_examples/architecture/dart/lib/hero_list_component.dart
+++ b/public/docs/_examples/architecture/dart/lib/hero_list_component.dart
@@ -1,5 +1,5 @@
// #docplaster
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
import 'hero_detail_component.dart';
diff --git a/public/docs/_examples/architecture/dart/lib/hero_service.dart b/public/docs/_examples/architecture/dart/lib/hero_service.dart
index e15db5f1cd..794e79927e 100644
--- a/public/docs/_examples/architecture/dart/lib/hero_service.dart
+++ b/public/docs/_examples/architecture/dart/lib/hero_service.dart
@@ -1,4 +1,4 @@
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'backend_service.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/architecture/dart/lib/logger_service.dart b/public/docs/_examples/architecture/dart/lib/logger_service.dart
index e1815da9a8..2d6d1c4f75 100644
--- a/public/docs/_examples/architecture/dart/lib/logger_service.dart
+++ b/public/docs/_examples/architecture/dart/lib/logger_service.dart
@@ -1,7 +1,7 @@
// #docregion
import 'dart:html';
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
/// A service for logging messages of various types.
///
diff --git a/public/docs/_examples/architecture/dart/pubspec.yaml b/public/docs/_examples/architecture/dart/pubspec.yaml
index 9466bdac16..9be156cfc7 100644
--- a/public/docs/_examples/architecture/dart/pubspec.yaml
+++ b/public/docs/_examples/architecture/dart/pubspec.yaml
@@ -5,9 +5,9 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
- angular2: 2.0.0-beta.11
+ angular2: 2.0.0-beta.13.1
browser: ^0.10.0
- dart_to_js_script_rewriter: ^0.1.0
+ dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives: 'package:angular2/common.dart#CORE_DIRECTIVES'
diff --git a/public/docs/_examples/architecture/dart/web/main.dart b/public/docs/_examples/architecture/dart/web/main.dart
index c96db07bb8..acb382ab8e 100644
--- a/public/docs/_examples/architecture/dart/web/main.dart
+++ b/public/docs/_examples/architecture/dart/web/main.dart
@@ -1,5 +1,6 @@
// #docregion
-import 'package:angular2/bootstrap.dart';
+import 'package:angular2/platform/browser.dart';
+
import 'package:developer_guide_intro/backend_service.dart';
import 'package:developer_guide_intro/hero_list_component.dart';
import 'package:developer_guide_intro/hero_service.dart';
diff --git a/public/docs/_examples/attribute-directives/dart/lib/app_component.dart b/public/docs/_examples/attribute-directives/dart/lib/app_component.dart
index 0d3ad7595b..2494fc3fd7 100644
--- a/public/docs/_examples/attribute-directives/dart/lib/app_component.dart
+++ b/public/docs/_examples/attribute-directives/dart/lib/app_component.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'highlight_directive.dart';
diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart
index 0fb5832160..a6c0856cc4 100644
--- a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart
+++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart
@@ -1,6 +1,6 @@
// #docplaster
// #docregion full
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
@Directive(selector: '[my-highlight]', host: const {
'(mouseenter)': 'onMouseEnter()',
diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart
index 4fef486203..3b79e66a3b 100644
--- a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart
+++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart
@@ -1,7 +1,7 @@
// #docregion
library attribute_directives.highlight_directive;
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
@Directive(selector: '[my-highlight]')
class Highlight {
diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart
index 1561af0535..8c540b3a6a 100644
--- a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart
+++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
@Directive(selector: '[my-highlight]',
// #docregion host
diff --git a/public/docs/_examples/attribute-directives/dart/pubspec.yaml b/public/docs/_examples/attribute-directives/dart/pubspec.yaml
index 25f96209c1..897e7dd174 100644
--- a/public/docs/_examples/attribute-directives/dart/pubspec.yaml
+++ b/public/docs/_examples/attribute-directives/dart/pubspec.yaml
@@ -5,9 +5,9 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
- angular2: 2.0.0-beta.11
+ angular2: 2.0.0-beta.13.1
browser: ^0.10.0
- dart_to_js_script_rewriter: ^0.1.0
+ dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives: 'package:angular2/common.dart#CORE_DIRECTIVES'
diff --git a/public/docs/_examples/attribute-directives/dart/web/main.dart b/public/docs/_examples/attribute-directives/dart/web/main.dart
index ce74487a47..0703b7ab25 100644
--- a/public/docs/_examples/attribute-directives/dart/web/main.dart
+++ b/public/docs/_examples/attribute-directives/dart/web/main.dart
@@ -1,5 +1,6 @@
// #docregion
-import 'package:angular2/bootstrap.dart';
+import 'package:angular2/platform/browser.dart';
+
import 'package:attribute_directives/app_component.dart';
main() {
diff --git a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.2.ts b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.2.ts
index 9cf0b95970..1f42c5773f 100644
--- a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.2.ts
+++ b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.2.ts
@@ -12,8 +12,10 @@ import {Directive, ElementRef, Input} from 'angular2/core';
})
export class HighlightDirective {
+
// #docregion ctor
- constructor(private el: ElementRef) { }
+ private _el:HTMLElement;
+ constructor(el: ElementRef) { this._el = el.nativeElement; }
// #enddocregion ctor
// #docregion mouse-methods
@@ -21,7 +23,7 @@ export class HighlightDirective {
onMouseLeave() { this._highlight(null); }
private _highlight(color: string) {
- this.el.nativeElement.style.backgroundColor = color;
+ this._el.style.backgroundColor = color;
}
// #enddocregion mouse-methods
diff --git a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts
index 6a26780057..4380174c8f 100644
--- a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts
+++ b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts
@@ -12,6 +12,9 @@ import {Directive, ElementRef, Input} from 'angular2/core';
// #docregion class-1
export class HighlightDirective {
+
+ private _defaultColor = 'red';
+ private _el:HTMLElement;
// #enddocregion class-1
// #enddocregion full
/*
@@ -20,21 +23,21 @@ export class HighlightDirective {
// #enddocregion highlight
*/
// #docregion full
+
+// #docregion defaultColor
+ @Input() set defaultColor(colorName:string){
+ this._defaultColor = colorName || this._defaultColor;
+ }
+// #enddocregion defaultColor
// #docregion class-1
+
// #docregion color
@Input('myHighlight') highlightColor: string;
// #enddocregion color
- private _defaultColor = 'red';
// #enddocregion class-1
- // #docregion defaultColor
- @Input() set defaultColor(colorName:string){
- this._defaultColor = colorName || this._defaultColor;
- }
- // #enddocregion defaultColor
// #docregion class-1
-
- constructor(private el: ElementRef) { }
+ constructor(el: ElementRef) { this._el = el.nativeElement; }
// #docregion mouse-enter
onMouseEnter() { this._highlight(this.highlightColor || this._defaultColor); }
@@ -42,7 +45,7 @@ export class HighlightDirective {
onMouseLeave() { this._highlight(null); }
private _highlight(color:string) {
- this.el.nativeElement.style.backgroundColor = color;
+ this._el.style.backgroundColor = color;
}
}
// #enddocregion class-1
diff --git a/public/docs/_examples/cb-component-communication/ts/app/hero.ts b/public/docs/_examples/cb-component-communication/ts/app/hero.ts
index 5b99f17132..16ce60d8ed 100644
--- a/public/docs/_examples/cb-component-communication/ts/app/hero.ts
+++ b/public/docs/_examples/cb-component-communication/ts/app/hero.ts
@@ -1,4 +1,4 @@
-export interface Hero {
+export class Hero {
name: string;
}
diff --git a/public/docs/_examples/cb-dependency-injection/e2e-spec.js b/public/docs/_examples/cb-dependency-injection/e2e-spec.js
new file mode 100644
index 0000000000..aeb0e68b17
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/e2e-spec.js
@@ -0,0 +1,98 @@
+describe('Dependency Injection Cookbook', function () {
+
+ beforeAll(function () {
+ browser.get('');
+ });
+
+ it('should render Logged in User example', function () {
+ var loggedInUser = element.all(by.xpath('//h3[text()="Logged in user"]')).get(0);
+ expect(loggedInUser).toBeDefined();
+ });
+
+ it('"Bombasto" should be the logged in user', function () {
+ loggedInUser = element.all(by.xpath('//div[text()="Name: Bombasto"]')).get(0);
+ expect(loggedInUser).toBeDefined();
+ });
+
+ it('should render sorted heroes', function () {
+ var sortedHeroes = element.all(by.xpath('//h3[text()="Sorted Heroes" and position()=1]')).get(0);
+ expect(sortedHeroes).toBeDefined();
+ });
+
+ it('Mr. Nice should be in sorted heroes', function () {
+ var sortedHero = element.all(by.xpath('//sorted-heroes/[text()="Mr. Nice" and position()=2]')).get(0);
+ expect(sortedHero).toBeDefined();
+ });
+
+ it('RubberMan should be in sorted heroes', function () {
+ sortedHero = element.all(by.xpath('//sorted-heroes/[text()="RubberMan" and position()=3]')).get(0);
+ expect(sortedHero).toBeDefined();
+ });
+
+ it('Magma should be in sorted heroes', function () {
+ sortedHero = element.all(by.xpath('//sorted-heroes/[text()="Magma"]')).get(0);
+ expect(sortedHero).toBeDefined();
+ });
+
+ it('should render Hero of the Month', function () {
+ var heroOfTheMonth = element.all(by.xpath('//h3[text()="Hero of the month"]')).get(0);
+ expect(heroOfTheMonth).toBeDefined();
+ });
+
+ it('should render Hero Bios', function () {
+ var heroBios = element.all(by.xpath('//h3[text()="Hero Bios"]')).get(0);
+ expect(heroBios).toBeDefined();
+ });
+
+ it('should render Magma\'s description in Hero Bios', function () {
+ var magmaText = element.all(by.xpath('//textarea[text()="Hero of all trades"]')).get(0);
+ expect(magmaText).toBeDefined();
+ });
+
+ it('should render Magma\'s phone in Hero Bios and Contacts', function () {
+ var magmaPhone = element.all(by.xpath('//div[text()="Phone #: 555-555-5555"]')).get(0);
+ expect(magmaPhone).toBeDefined();
+ });
+
+ it('should render Hero-of-the-Month runner-ups', function () {
+ var runnersUp = element(by.id('rups')).getText();
+ expect(runnersUp).toContain('RubberMan, Mr. Nice');
+ });
+
+ it('should render DateLogger log entry in Hero-of-the-Month', function () {
+ var logs = element.all(by.id('logs')).get(0).getText();
+ expect(logs).toContain('INFO: starting up at');
+ });
+
+ it('should highlight Hero Bios and Contacts container when mouseover', function () {
+ var target = element(by.css('div[myHighlight="yellow"]'))
+ var yellow = "rgba(255, 255, 0, 1)";
+
+ expect(target.getCssValue('background-color')).not.toEqual(yellow);
+ browser.actions().mouseMove(target).perform();
+ expect(target.getCssValue('background-color')).toEqual(yellow);
+ });
+
+ describe('in Parent Finder', function () {
+ var cathy1 = element(by.css('alex cathy'));
+ var craig1 = element(by.css('alex craig'));
+ var carol1 = element(by.css('alex carol p'));
+ var carol2 = element(by.css('barry carol p'));
+
+ it('"Cathy" should find "Alex" via the component class', function () {
+ expect(cathy1.getText()).toContain('Found Alex via the component');
+ });
+
+ it('"Craig" should not find "Alex" via the base class', function () {
+ expect(craig1.getText()).toContain('Did not find Alex via the base');
+ });
+
+ it('"Carol" within "Alex" should have "Alex" parent', function () {
+ expect(carol1.getText()).toContain('Alex');
+ });
+
+ it('"Carol" within "Barry" should have "Barry" parent', function () {
+ expect(carol2.getText()).toContain('Barry');
+ });
+ })
+});
diff --git a/public/docs/_examples/cb-dependency-injection/ts/.gitignore b/public/docs/_examples/cb-dependency-injection/ts/.gitignore
new file mode 100644
index 0000000000..cf44e148ba
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/.gitignore
@@ -0,0 +1 @@
+**/*.js
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html b/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html
new file mode 100644
index 0000000000..c27281f2af
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html
@@ -0,0 +1,39 @@
+
DI Cookbook
+
+
Logged in user
+
Name: {{userContext.name}}
+
Role: {{userContext.role}}
+
+
+
+
Hero Bios
+
+
+
+
+
+
Hero Bios and Contacts
+
+
+
+
+
+
+
+
+
+
+
+
+
Unsorted Heroes
+
+
+
+
+
Sorted Heroes
+
+
+
+
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/app.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/app.component.ts
new file mode 100644
index 0000000000..2e4485f665
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/app.component.ts
@@ -0,0 +1,46 @@
+// #docregion
+import { Component } from 'angular2/core';
+
+import { HeroBiosComponent,
+ HeroBiosAndContactsComponent} from './hero-bios.component';
+import { HeroOfTheMonthComponent } from './hero-of-the-month.component';
+import { HeroesBaseComponent,
+ SortedHeroesComponent } from './sorted-heroes.component';
+import { HighlightDirective } from './highlight.directive';
+import { ParentFinderComponent } from './parent-finder.component';
+
+const DIRECTIVES = [
+ HeroBiosComponent, HeroBiosAndContactsComponent,
+ HeroesBaseComponent, SortedHeroesComponent,
+ HeroOfTheMonthComponent,
+ HighlightDirective,
+ ParentFinderComponent
+];
+
+// #docregion import-services
+import { LoggerService } from './logger.service';
+import { UserContextService } from './user-context.service';
+import { UserService } from './user.service';
+
+@Component({
+ selector: 'my-app',
+ templateUrl:'app/app.component.html',
+ directives: DIRECTIVES,
+// #docregion providers
+ providers: [LoggerService, UserContextService, UserService]
+// #enddocregion providers
+})
+export class AppComponent {
+// #enddocregion import-services
+
+ private userId:number = 1;
+
+ // #docregion ctor
+ constructor(logger:LoggerService, public userContext:UserContextService) {
+ userContext.loadUser(this.userId);
+ logger.logInfo('AppComponent initialized');
+ }
+ // #enddocregion ctor
+// #docregion import-services
+}
+// #enddocregion import-services
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/date-logger.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/date-logger.service.ts
new file mode 100644
index 0000000000..125ba37c2b
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/date-logger.service.ts
@@ -0,0 +1,37 @@
+/* tslint:disable:one-line:check-open-brace*/
+// #docregion
+import { Injectable } from 'angular2/core';
+import { LoggerService } from './logger.service';
+
+// #docregion minimal-logger
+// class used as a restricting interface (hides other public members)
+export abstract class MinimalLogger {
+ logInfo: (msg: string) => void;
+ logs: string[];
+}
+// #enddocregion minimal-logger
+
+/*
+// Transpiles to:
+// #docregion minimal-logger-transpiled
+ var MinimalLogger = (function () {
+ function MinimalLogger() {}
+ return MinimalLogger;
+ }());
+ exports("MinimalLogger", MinimalLogger);
+// #enddocregion minimal-logger-transpiled
+ */
+
+// #docregion date-logger-service
+@Injectable()
+// #docregion date-logger-service-signature
+export class DateLoggerService extends LoggerService implements MinimalLogger
+// #enddocregion date-logger-service-signature
+{
+ logInfo(msg: any) { super.logInfo(stamp(msg)); }
+ logDebug(msg: any) { super.logInfo(stamp(msg)); }
+ logError(msg: any) { super.logError(stamp(msg)); }
+}
+
+function stamp(msg: any) { return msg + ' at ' + new Date(); }
+// #enddocregion date-logger-service
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero-bio.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero-bio.component.ts
new file mode 100644
index 0000000000..6b006fcc56
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero-bio.component.ts
@@ -0,0 +1,29 @@
+// #docregion
+import {Component, Input, OnInit} from 'angular2/core';
+
+import {Hero} from './hero';
+import {HeroCacheService} from './hero-cache.service';
+
+// #docregion component
+@Component({
+ selector:'hero-bio',
+ // #docregion template
+ template:`
+ {{hero.name}}
+
+ `,
+ // #enddocregion template
+ providers: [HeroCacheService]
+})
+
+export class HeroBioComponent implements OnInit {
+
+ @Input() heroId:number;
+
+ constructor(private _heroCache:HeroCacheService) { }
+
+ ngOnInit() { this._heroCache.fetchCachedHero(this.heroId); }
+
+ get hero() { return this._heroCache.hero; }
+}
+// #enddocregion component
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero-bios.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero-bios.component.ts
new file mode 100644
index 0000000000..9d14daf648
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero-bios.component.ts
@@ -0,0 +1,52 @@
+// #docplaster
+// #docregion
+import { Component} from 'angular2/core';
+
+import { HeroContactComponent } from './hero-contact.component';
+import { HeroBioComponent } from './hero-bio.component';
+import { HeroService } from './hero.service';
+import { LoggerService } from './logger.service';
+
+//////// HeroBiosComponent ////
+// #docregion simple
+@Component({
+ selector:'hero-bios',
+ template:`
+
+
+ `,
+ directives:[HeroBioComponent],
+ providers: [HeroService]
+})
+export class HeroBiosComponent{
+// #enddocregion simple
+// #docregion ctor
+ constructor(logger: LoggerService) {
+ logger.logInfo('Creating HeroBiosComponent');
+ }
+// #enddocregion ctor
+// #docregion simple
+}
+// #enddocregion simple
+
+//////// HeroBiosAndContactsComponent ////
+// #docregion hero-bios-and-contacts
+@Component({
+ selector:'hero-bios-and-contacts',
+ // #docregion template
+ template:`
+
+
+ `,
+ // #enddocregion template
+ directives:[HeroBioComponent, HeroContactComponent],
+ // #docregion class-provider
+ providers: [HeroService]
+ // #enddocregion class-provider
+})
+export class HeroBiosAndContactsComponent{
+ constructor(logger: LoggerService) {
+ logger.logInfo('Creating HeroBiosAndContactsComponent');
+ }
+}
+// #enddocregion hero-bios-and-contacts
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero-cache.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero-cache.service.ts
new file mode 100644
index 0000000000..c0c7ce581f
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero-cache.service.ts
@@ -0,0 +1,19 @@
+// #docregion
+import {Injectable} from 'angular2/core';
+import {Hero} from './hero';
+import {HeroService} from './hero.service';
+
+// #docregion service
+@Injectable()
+export class HeroCacheService {
+ hero:Hero;
+ constructor(private _heroService:HeroService){}
+
+ fetchCachedHero(id:number){
+ if (!this.hero) {
+ this.hero = this._heroService.getHeroById(id);
+ }
+ return this.hero
+ }
+}
+// #enddocregion service
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero-contact.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero-contact.component.ts
new file mode 100644
index 0000000000..42163d3f3e
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero-contact.component.ts
@@ -0,0 +1,39 @@
+// #docplaster
+// #docregion
+import {Component, ElementRef, Host, Inject, Optional} from 'angular2/core';
+import {HeroCacheService} from './hero-cache.service';
+import {LoggerService} from './logger.service';
+
+// #docregion component
+@Component({
+ selector:'hero-contact',
+ template:`
+ Phone #: {{phoneNumber}}
+ !!!
`
+})
+export class HeroContactComponent {
+
+ hasLogger = false;
+
+ constructor(
+ // #docregion ctor-params
+ @Host() // limit to the host component's instance of the HeroCacheService
+ private _heroCache: HeroCacheService,
+
+ @Host() // limit search for logger; hides the application-wide logger
+ @Optional() // ok if the logger doesn't exist
+ private _loggerService: LoggerService
+ // #enddocregion ctor-params
+ ) {
+ if (_loggerService) {
+ this.hasLogger = true;
+ _loggerService.logInfo('HeroContactComponent can log!');
+ }
+ // #docregion ctor
+ }
+ // #enddocregion ctor
+
+ get phoneNumber() { return this._heroCache.hero.phone; }
+
+}
+// #enddocregion component
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero-data.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero-data.ts
new file mode 100644
index 0000000000..18133fd771
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero-data.ts
@@ -0,0 +1,14 @@
+// #docregion
+import {Hero} from './hero';
+
+export class HeroData {
+ createDb() {
+ let heroes = [
+ new Hero(1,"Windstorm"),
+ new Hero(2,"Bombasto"),
+ new Hero(3,"Magneta"),
+ new Hero(4,"Tornado")
+ ];
+ return {heroes};
+ }
+}
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero-of-the-month.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero-of-the-month.component.ts
new file mode 100644
index 0000000000..02dcae4824
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero-of-the-month.component.ts
@@ -0,0 +1,75 @@
+/* tslint:disable:one-line:check-open-brace*/
+// #docplaster
+// #docregion opaque-token
+import {OpaqueToken} from 'angular2/core';
+
+export const TITLE = new OpaqueToken('title');
+// #enddocregion opaque-token
+
+// #docregion hero-of-the-month
+import { Component, Inject, provide } from 'angular2/core';
+
+import { DateLoggerService,
+ MinimalLogger } from './date-logger.service';
+import { Hero } from './hero';
+import { HeroService } from './hero.service';
+import { LoggerService } from './logger.service';
+import { RUNNERS_UP,
+ runnersUpFactory } from './runners-up';
+
+// #enddocregion hero-of-the-month
+// #docregion some-hero
+const someHero = new Hero(42, 'Magma', 'Had a great month!', '555-555-5555');
+// #enddocregion some-hero
+
+const template = `
+ {{title}}
+ Winner: {{heroOfTheMonth.name}}
+ Reason for award: {{heroOfTheMonth.description}}
+ Runners-up: {{runnersUp}}
+
+ Logs:
+
+ `;
+
+// #docregion hero-of-the-month
+@Component({
+ selector: 'hero-of-the-month',
+ template: template,
+ providers: [
+ // #docregion use-value
+ provide(Hero, {useValue: someHero}),
+ // #docregion provide-opaque-token
+ provide(TITLE, {useValue: 'Hero of the Month'}),
+ // #enddocregion provide-opaque-token
+ // #enddocregion use-value
+ // #docregion use-class
+ provide(HeroService, {useClass: HeroService}),
+ provide(LoggerService, {useClass: DateLoggerService}),
+ // #enddocregion use-class
+ // #docregion use-existing
+ provide(MinimalLogger, {useExisting: LoggerService}),
+ // #enddocregion use-existing
+ // #docregion provide-opaque-token, use-factory
+ provide(RUNNERS_UP, {useFactory: runnersUpFactory(2), deps: [Hero, HeroService]})
+ // #enddocregion provide-opaque-token, use-factory
+ ]
+})
+export class HeroOfTheMonthComponent {
+ logs: string[] = [];
+
+// #docregion ctor-signature
+ constructor(
+ logger: MinimalLogger,
+ public heroOfTheMonth: Hero,
+ @Inject(RUNNERS_UP) public runnersUp: string,
+ @Inject(TITLE) public title: string)
+// #enddocregion ctor-signature
+ {
+ this.logs = logger.logs;
+ logger.logInfo('starting up');
+ }
+}
+// #enddocregion hero-of-the-month
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts
new file mode 100644
index 0000000000..274753ae8d
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero.service.ts
@@ -0,0 +1,22 @@
+// #docregion
+import {Injectable} from 'angular2/core';
+import {Hero} from './hero';
+
+@Injectable()
+export class HeroService {
+
+ //TODO move to database
+ private _heros:Array = [
+ new Hero(1, 'RubberMan','Hero of many talents', '123-456-7899'),
+ new Hero(2, 'Magma','Hero of all trades', '555-555-5555'),
+ new Hero(3, 'Mr. Nice','The name says it all','111-222-3333')
+ ];
+
+ getHeroById(id:number):Hero{
+ return this._heros.filter(hero => hero.id === id)[0];
+ }
+
+ getAllHeroes():Array{
+ return this._heros;
+ }
+}
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/hero.ts b/public/docs/_examples/cb-dependency-injection/ts/app/hero.ts
new file mode 100644
index 0000000000..51ce8ebbff
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/hero.ts
@@ -0,0 +1,9 @@
+// #docregion
+export class Hero{
+ constructor(
+ public id: number,
+ public name:string,
+ public description?:string,
+ public phone?:string) {
+ }
+}
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/highlight.directive.ts b/public/docs/_examples/cb-dependency-injection/ts/app/highlight.directive.ts
new file mode 100644
index 0000000000..6d054e1a0b
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/highlight.directive.ts
@@ -0,0 +1,28 @@
+// #docplaster
+// #docregion
+import {Directive, ElementRef, Input} from 'angular2/core';
+
+@Directive({
+ selector: '[myHighlight]',
+ host: {
+ '(mouseenter)': 'onMouseEnter()',
+ '(mouseleave)': 'onMouseLeave()'
+ }
+})
+export class HighlightDirective {
+
+ @Input('myHighlight') highlightColor: string;
+
+ private _el: HTMLElement;
+
+ constructor(el: ElementRef) {
+ this._el = el.nativeElement;
+ }
+
+ onMouseEnter() { this._highlight(this.highlightColor || 'cyan'); }
+ onMouseLeave() { this._highlight(null); }
+
+ private _highlight(color: string) {
+ this._el.style.backgroundColor = color;
+ }
+}
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/logger.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/logger.service.ts
new file mode 100644
index 0000000000..ecc75350e3
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/logger.service.ts
@@ -0,0 +1,16 @@
+// #docregion
+import {Injectable} from 'angular2/core';
+
+@Injectable()
+export class LoggerService {
+ logs: string[] = [];
+
+ logInfo(msg: any) { this.log(`INFO: ${msg}`); }
+ logDebug(msg: any) { this.log(`DEBUG: ${msg}`); }
+ logError(msg: any) { this.log(`ERROR: ${msg}`, true); }
+
+ private log(msg: any, isErr = false) {
+ this.logs.push(msg);
+ isErr ? console.error(msg) : console.log(msg);
+ }
+}
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/main.ts b/public/docs/_examples/cb-dependency-injection/ts/app/main.ts
new file mode 100644
index 0000000000..b1e35e2a67
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/main.ts
@@ -0,0 +1,25 @@
+// #docregion
+import { bootstrap } from 'angular2/platform/browser';
+import { provide } from 'angular2/core';
+import { XHRBackend } from 'angular2/http';
+
+import { LocationStrategy,
+ HashLocationStrategy,
+ ROUTER_PROVIDERS } from 'angular2/router';
+
+import { HeroData } from './hero-data';
+import { InMemoryBackendService,
+ SEED_DATA } from 'a2-in-memory-web-api/core';
+
+import { AppComponent } from './app.component';
+
+// #docregion bootstrap
+bootstrap(AppComponent, [
+ ROUTER_PROVIDERS,
+ provide(LocationStrategy,
+ {useClass: HashLocationStrategy}),
+
+ provide(XHRBackend, { useClass: InMemoryBackendService }), // in-mem server
+ provide(SEED_DATA, { useClass: HeroData }) // in-mem server data
+]).catch((err: any) => console.error(err));
+// #enddocregion bootstrap
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/parent-finder.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/parent-finder.component.ts
new file mode 100644
index 0000000000..4099ec6af9
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/parent-finder.component.ts
@@ -0,0 +1,227 @@
+/* tslint:disable:no-unused-variable */
+/* tslint:disable:one-line:check-open-brace*/
+// #docplaster
+// #docregion
+import { Component, forwardRef, Optional, provide, SkipSelf } from 'angular2/core';
+
+// A component base class (see AlexComponent)
+export abstract class Base { name = 'Count Basie'; }
+
+// Marker class, used as an interface
+// #docregion parent
+export abstract class Parent { name: string; }
+// #enddocregion parent
+
+const DifferentParent = Parent;
+
+// #docregion provide-parent, provide-the-parent
+// Helper method to provide the current component instance in the name of a `parentType`.
+// #enddocregion provide-the-parent
+// The `parentType` defaults to `Parent` when omitting the second parameter.
+// #docregion provide-the-parent
+const provideParent =
+// #enddocregion provide-parent, provide-the-parent
+// #docregion provide-parent
+ (component: any, parentType?: any) =>
+ provide(parentType || Parent, { useExisting: forwardRef(() => component) });
+// #enddocregion provide-parent
+
+// Simpler syntax version that always provides the component in the name of `Parent`.
+const provideTheParent =
+// #docregion provide-the-parent
+ (component: any) => provide(Parent, { useExisting: forwardRef(() => component) });
+// #enddocregion provide-the-parent
+
+
+///////// C - Child //////////
+// #docregion carol
+const templateC = `
+
+
{{name}}
+
My parent is {{parent?.name}}
+
`;
+
+@Component({
+ selector: 'carol',
+ template: templateC
+})
+// #docregion carol-class
+export class CarolComponent {
+ name= 'Carol';
+ // #docregion carol-ctor
+ constructor( @Optional() public parent: Parent ) { }
+ // #enddocregion carol-ctor
+}
+// #enddocregion carol-class
+// #enddocregion carol
+
+@Component({
+ selector: 'chris',
+ template: templateC
+})
+export class ChrisComponent {
+ name= 'Chris';
+ constructor( @Optional() public parent: Parent ) { }
+}
+
+////// Craig ///////////
+/**
+ * Show we cannot inject a parent by its base class.
+ */
+// #docregion craig
+@Component({
+ selector: 'craig',
+ template: `
+
+
Craig
+ {{alex ? 'Found' : 'Did not find'}} Alex via the base class.
+ `
+})
+export class CraigComponent {
+ constructor( @Optional() public alex: Base ) { }
+}
+// #enddocregion craig
+
+// #docregion C_DIRECTIVES
+const C_DIRECTIVES = [
+ CarolComponent, ChrisComponent, CraigComponent,
+ forwardRef(() => CathyComponent)
+];
+// #enddocregion C_DIRECTIVES
+
+//////// B - Parent /////////
+// #docregion barry
+const templateB = `
+
+
+
{{name}}
+
My parent is {{parent?.name}}
+
+
+
+
`;
+
+@Component({
+ selector: 'barry',
+ template: templateB,
+ directives: C_DIRECTIVES,
+ providers: [ provide(Parent, { useExisting: forwardRef(() => BarryComponent) }) ]
+})
+export class BarryComponent implements Parent {
+ name = 'Barry';
+// #docregion barry-ctor
+ constructor( @SkipSelf() @Optional() public parent: Parent ) { }
+// #enddocregion barry-ctor
+}
+// #enddocregion barry
+
+@Component({
+ selector: 'bob',
+ template: templateB,
+ directives: C_DIRECTIVES,
+ providers: [ provideParent(BobComponent) ]
+})
+export class BobComponent implements Parent {
+ name= 'Bob';
+ constructor( @SkipSelf() @Optional() public parent: Parent ) { }
+}
+
+@Component({
+ selector: 'beth',
+ template: templateB,
+ directives: C_DIRECTIVES,
+// #docregion beth-providers
+ providers: [ provideParent(BethComponent, DifferentParent) ]
+// #enddocregion beth-providers
+})
+export class BethComponent implements Parent {
+ name= 'Beth';
+ constructor( @SkipSelf() @Optional() public parent: Parent ) { }
+}
+
+const B_DIRECTIVES = [ BarryComponent, BethComponent, BobComponent ];
+
+///////// A - Grandparent //////
+
+// #docregion alex, alex-1
+@Component({
+ selector: 'alex',
+ template: `
+
+
{{name}}
+
+
+
+ `,
+// #enddocregion alex-1
+// #docregion alex-providers
+ providers: [ provide(Parent, { useExisting: forwardRef(() => AlexComponent) }) ],
+// #enddocregion alex-providers
+// #docregion alex-1
+ directives: C_DIRECTIVES
+})
+// #enddocregion alex-1
+// Todo: Add `... implements Parent` to class signature
+// #docregion alex-1
+// #docregion alex-class-signature
+export class AlexComponent extends Base
+// #enddocregion alex-class-signature
+{
+ name= 'Alex';
+}
+// #enddocregion alex, alex-1
+
+/////
+
+// #docregion alice
+@Component({
+ selector: 'alice',
+ template: `
+
+
{{name}}
+
+
+
+
+ `,
+ directives: [ B_DIRECTIVES, C_DIRECTIVES ],
+// #docregion alice-providers
+ providers: [ provideParent(AliceComponent) ]
+// #enddocregion alice-providers
+})
+// #docregion alice-class-signature
+export class AliceComponent implements Parent
+// #enddocregion alice-class-signature
+{
+ name= 'Alice';
+}
+// #enddocregion alice
+
+////// Cathy ///////////
+/**
+ * Show we can inject a parent by component type
+ */
+// #docregion cathy
+@Component({
+ selector: 'cathy',
+ template: `
+
+
Cathy
+ {{alex ? 'Found' : 'Did not find'}} Alex via the component class.
+ `
+})
+export class CathyComponent {
+ constructor( @Optional() public alex: AlexComponent ) { }
+}
+// #enddocregion cathy
+
+///////// ParentFinder //////
+@Component({
+ selector: 'parent-finder',
+ template: `
+ Parent Finder
+
+ `,
+ directives: [ AlexComponent, AliceComponent ]
+})
+export class ParentFinderComponent { }
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/runners-up.ts b/public/docs/_examples/cb-dependency-injection/ts/app/runners-up.ts
new file mode 100644
index 0000000000..a2d79df35e
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/runners-up.ts
@@ -0,0 +1,25 @@
+// #docplaster
+// #docregion
+import {OpaqueToken} from 'angular2/core';
+import {Hero} from './hero';
+import {HeroService} from './hero.service';
+
+// #docregion runners-up
+export const RUNNERS_UP = new OpaqueToken('RunnersUp');
+// #docregion runners-up
+
+// #docregion factory-synopsis
+export function runnersUpFactory(take: number) {
+ return (winner: Hero, heroService: HeroService): string => {
+ /* ... */
+// #enddocregion factory-synopsis
+ return heroService
+ .getAllHeroes()
+ .filter((hero) => hero.name !== winner.name)
+ .map(hero => hero.name)
+ .slice(0, Math.max(0, take))
+ .join(', ');
+// #docregion factory-synopsis
+ };
+};
+// #enddocregion factory-synopsis
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/sorted-heroes.component.ts b/public/docs/_examples/cb-dependency-injection/ts/app/sorted-heroes.component.ts
new file mode 100644
index 0000000000..2a45367044
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/sorted-heroes.component.ts
@@ -0,0 +1,51 @@
+// #docplaster
+// #docregion
+import {Component, OnInit} from 'angular2/core';
+import {Hero} from './hero';
+import {HeroService} from './hero.service';
+
+/////// HeroesBaseComponent /////
+// #docregion heroes-base, injection
+@Component({
+ selector: 'unsorted-heroes',
+ template: `{{hero.name}}
`,
+ providers: [HeroService]
+})
+export class HeroesBaseComponent implements OnInit {
+ constructor(private _heroService: HeroService) { }
+// #enddocregion injection
+
+ heroes: Array;
+
+ ngOnInit() {
+ this.heroes = this._heroService.getAllHeroes();
+ this._afterGetHeroes();
+ }
+
+ // Post-process heroes in derived class override.
+ protected _afterGetHeroes() {}
+
+// #docregion injection
+}
+// #enddocregion heroes-base,injection
+
+/////// SortedHeroesComponent /////
+// #docregion sorted-heroes
+@Component({
+ selector: 'sorted-heroes',
+ template: `{{hero.name}}
`,
+ providers: [HeroService]
+})
+export class SortedHeroesComponent extends HeroesBaseComponent {
+ constructor(heroService: HeroService) {
+ super(heroService);
+ }
+
+ protected _afterGetHeroes() {
+ this.heroes = this.heroes.sort((h1, h2) => {
+ return h1.name < h2.name ? -1 :
+ (h1.name > h2.name ? 1 : 0);
+ });
+ }
+}
+// #enddocregion sorted-heroes
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/user-context.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/user-context.service.ts
new file mode 100644
index 0000000000..b241675d31
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/user-context.service.ts
@@ -0,0 +1,32 @@
+// #docplaster
+// #docregion
+import {Injectable} from 'angular2/core';
+import {LoggerService} from './logger.service';
+import {UserService} from './user.service';
+
+// #docregion injectables, injectable
+@Injectable()
+export class UserContextService {
+// #enddocregion injectables, injectable
+ name:string;
+ role:string;
+ loggedInSince:Date;
+
+ // #docregion ctor, injectables
+ constructor(private _userService:UserService, private _loggerService:LoggerService){
+ // #enddocregion ctor, injectables
+ this.loggedInSince = new Date();
+ // #docregion ctor, injectables
+ }
+ // #enddocregion ctor, injectables
+
+ loadUser(userId:number){
+ let user = this._userService.getUserById(userId);
+ this.name = user.name;
+ this.role = user.role;
+
+ this._loggerService.logDebug('loaded User');
+ }
+// #docregion injectables, injectable
+}
+// #enddocregion injectables, injectable
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/user.service.ts b/public/docs/_examples/cb-dependency-injection/ts/app/user.service.ts
new file mode 100644
index 0000000000..f2d44d7a26
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/user.service.ts
@@ -0,0 +1,10 @@
+// #docregion
+import {Injectable} from 'angular2/core';
+
+@Injectable()
+export class UserService {
+
+ getUserById(userId:number):any{
+ return {name:'Bombasto',role:'Admin'};
+ }
+}
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/example-config.json b/public/docs/_examples/cb-dependency-injection/ts/example-config.json
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/docs/_examples/cb-dependency-injection/ts/index.html b/public/docs/_examples/cb-dependency-injection/ts/index.html
new file mode 100644
index 0000000000..66db40eb30
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/index.html
@@ -0,0 +1,44 @@
+
+
+
+
+ Dependency Injection
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Loading app...
+
+
+
diff --git a/public/docs/_examples/cb-dependency-injection/ts/plnkr.json b/public/docs/_examples/cb-dependency-injection/ts/plnkr.json
new file mode 100644
index 0000000000..d20b01cf1d
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/plnkr.json
@@ -0,0 +1,9 @@
+{
+ "description": "Dependency Injection",
+ "files":[
+ "!**/*.d.ts",
+ "!**/*.js",
+ "!**/*.[1].*"
+ ],
+ "tags":["cookbook"]
+}
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dependency-injection/ts/sample.css b/public/docs/_examples/cb-dependency-injection/ts/sample.css
new file mode 100644
index 0000000000..a8b59efd05
--- /dev/null
+++ b/public/docs/_examples/cb-dependency-injection/ts/sample.css
@@ -0,0 +1,26 @@
+.di-component{
+ padding: 10px;
+ width:300px;
+ margin-bottom: 10px;
+}
+div[myHighlight] {
+ padding: 2px 8px;
+}
+
+/* Parent Finder */
+.a, .b, .c {
+ margin: 6px 2px 6px;
+ padding: 4px 6px;
+}
+.a {
+ border: solid 2px black;
+}
+.b {
+ background: lightblue;
+ border: solid 1px darkblue;
+ display: flex;
+}
+.c {
+ background: pink;
+ border: solid 1px red;
+}
\ No newline at end of file
diff --git a/public/docs/_examples/cb-ts-to-js/e2e-spec.js b/public/docs/_examples/cb-ts-to-js/e2e-spec.js
new file mode 100644
index 0000000000..27b332e99e
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/e2e-spec.js
@@ -0,0 +1,73 @@
+describe('TypeScript to Javascript tests', function () {
+
+ beforeAll(function () {
+ browser.get('');
+ });
+
+ it('should display the basic component example', function () {
+ testTag('hero-view', 'Hero: Windstorm');
+ });
+
+ it('should display the component example with lifecycle methods', function () {
+ testTag('hero-lifecycle', 'Hero: Windstorm');
+ });
+
+ it('should display component with DI example', function () {
+ testTag('hero-di', 'Hero: Windstorm');
+ });
+
+ it('should display component with DI using @Inject example', function () {
+ testTag('hero-di-inject', 'Hero: Windstorm');
+ });
+
+ it('should support optional, attribute, and query injections', function () {
+ var app = element(by.css('hero-di-inject-additional'));
+ var h1 = app.element(by.css('h1'));
+ var okMsg = app.element(by.css('.ok-msg'));
+
+ expect(h1.getText()).toBe('Tour of Heroes');
+ app.element(by.buttonText('OK')).click();
+ expect(okMsg.getText()).toBe('OK!');
+ });
+
+ it('should support component with inputs and outputs', function () {
+ var app = element(by.css('hero-io'));
+ var confirmComponent = app.element(by.css('my-confirm'));
+
+ confirmComponent.element(by.buttonText('OK')).click();
+ expect(app.element(by.cssContainingText('span', 'OK clicked')).isPresent()).toBe(true);
+
+ confirmComponent.element(by.buttonText('Cancel')).click();
+ expect(app.element(by.cssContainingText('span', 'Cancel clicked')).isPresent()).toBe(true);
+ });
+
+ it('should support host bindings and host listeners', function() {
+ var app = element(by.css('heroes-bindings'));
+ var h1 = app.element(by.css('h1'));
+
+ expect(app.getAttribute('class')).toBe('heading');
+ expect(app.getAttribute('title')).toBe('Tooltip content');
+
+ h1.click();
+ expect(h1.getAttribute('class')).toBe('active');
+
+ h1.click();
+ browser.actions().doubleClick(h1).perform();
+ expect(h1.getAttribute('class')).toBe('active');
+ });
+
+ it('should support content and view queries', function() {
+ var app = element(by.css('heroes-queries'));
+ var windstorm = app.element(by.css('hero:first-child'));
+
+ app.element(by.buttonText('Activate')).click();
+ expect(windstorm.element(by.css('h2')).getAttribute('class')).toBe('active');
+ expect(windstorm.element(by.css('active-label')).getText()).toBe('Active');
+ });
+
+ function testTag(selector, expectedText) {
+ var component = element(by.css(selector));
+ expect(component.getText()).toBe(expectedText);
+ }
+
+});
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
new file mode 100644
index 0000000000..c060e2b39d
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/data.service.js
@@ -0,0 +1,13 @@
+(function(app) {
+
+ function DataService() {
+ }
+ DataService.annotations = [
+ new ng.core.Injectable()
+ ];
+ 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
new file mode 100644
index 0000000000..413ccfc8f3
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject-additional.component.js
@@ -0,0 +1,47 @@
+(function(app) {
+
+ // #docregion
+ var TitleComponent = ng.core.Component({
+ selector: 'hero-title',
+ template:
+ '{{titlePrefix}} {{title}}
' +
+ '' +
+ ''
+ }).Class({
+ constructor: [
+ [
+ new ng.core.Optional(),
+ new ng.core.Inject('titlePrefix')
+ ],
+ new ng.core.Attribute('title'),
+ [
+ new ng.core.Query('okMsg'),
+ ng.core.ElementRef
+ ],
+ function(titlePrefix, title, msg) {
+ this.titlePrefix = titlePrefix;
+ this.title = title;
+ this.msg = msg;
+ }
+ ],
+ ok: function() {
+ var msgEl =
+ this.msg.first.nativeElement;
+ msgEl.textContent = 'OK!';
+ }
+ });
+ // #enddocregion
+
+ var AppComponent = ng.core.Component({
+ selector: 'hero-di-inject-additional',
+ template: '' +
+ '' +
+ '',
+ directives: [TitleComponent]
+ }).Class({
+ constructor: function() { }
+ });
+
+ app.HeroDIInjectAdditionalComponent = AppComponent;
+
+})(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
new file mode 100644
index 0000000000..71bdbb57f9
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject.component.js
@@ -0,0 +1,39 @@
+(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
+
+ app.HeroDIInjectComponent = HeroComponent;
+
+})(window.app = window.app || {});
+
+(function(app) {
+// #docregion ctor
+ var HeroComponent = ng.core.Component({
+ selector: 'hero-di-inline2',
+ template: 'Hero: {{name}}
'
+ })
+ .Class({
+ constructor:
+ [new ng.core.Inject('heroName'),
+ function(name) {
+ this.name = name;
+ }]
+ });
+// #enddocregion ctor
+
+ app.HeroDIInjectComponent2 = HeroComponent;
+
+})(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
new file mode 100644
index 0000000000..90c3d69cba
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di-inline.component.js
@@ -0,0 +1,16 @@
+(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.HeroDIInlineComponent = HeroComponent;
+})(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
new file mode 100644
index 0000000000..2963258292
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-di.component.js
@@ -0,0 +1,20 @@
+(function(app) {
+
+ // #docregion
+ app.HeroDIComponent = HeroComponent;
+
+ function HeroComponent(dataService) {
+ this.name = dataService.getHeroName();
+ }
+ HeroComponent.parameters = [
+ app.DataService
+ ];
+ HeroComponent.annotations = [
+ new ng.core.Component({
+ selector: 'hero-di',
+ template: 'Hero: {{name}}
'
+ })
+ ];
+ // #enddocregion
+
+})(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
new file mode 100644
index 0000000000..2890e006a2
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-dsl.component.js
@@ -0,0 +1,23 @@
+// #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.HeroComponentDsl = HeroComponent;
+
+})(window.app = window.app || {});
+// #enddocregion appexport
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
new file mode 100644
index 0000000000..f00ce8065c
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-io.component.js
@@ -0,0 +1,57 @@
+(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',
+ directives: [ConfirmComponent]
+ })
+ ];
+ AppComponent.prototype.onOk = function() {
+ this.okClicked = true;
+ }
+ AppComponent.prototype.onCancel = function() {
+ this.cancelClicked = true;
+ }
+ app.HeroIOComponent = AppComponent;
+
+})(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
new file mode 100644
index 0000000000..b8a2148a64
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero-lifecycle.component.js
@@ -0,0 +1,21 @@
+// #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.HeroLifecycleComponent = HeroComponent;
+
+})(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
new file mode 100644
index 0000000000..f741285617
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/hero.component.js
@@ -0,0 +1,32 @@
+// #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 appexport
+ app.HeroComponent = HeroComponent;
+
+})(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
new file mode 100644
index 0000000000..0c4ee7d7cf
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/heroes-bindings.component.js
@@ -0,0 +1,30 @@
+(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.HeroesHostBindingsComponent = HeroesComponent;
+
+})(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
new file mode 100644
index 0000000000..a99d985b35
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/heroes-queries.component.js
@@ -0,0 +1,73 @@
+(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: 'hero',
+ template: '' +
+ '{{hero.name}} ' +
+ '' +
+ '
',
+ inputs: ['hero'],
+ queries: {
+ label: new ng.core.ContentChild(
+ ActiveLabelComponent)
+ }
+ }).Class({
+ constructor: function() { },
+ activate: function() {
+ this.active = true;
+ this.label.activate();
+ }
+ });
+ // #enddocregion content
+
+ // #docregion view
+ var AppComponent = ng.core.Component({
+ selector: 'heroes-queries',
+ template:
+ '' +
+ '' +
+ '' +
+ '',
+ directives: [
+ HeroComponent,
+ ActiveLabelComponent
+ ],
+ 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.HeroesQueriesComponent = AppComponent;
+
+})(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
new file mode 100644
index 0000000000..8603b116cc
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/app/main.js
@@ -0,0 +1,41 @@
+// #docplaster
+// #docregion appimport
+(function(app) {
+ // #enddocregion appimport
+
+ // #docregion ng2import
+ var provide =
+ ng.core.provide;
+ var bootstrap =
+ ng.platform.browser.bootstrap;
+ var LocationStrategy =
+ ng.router.LocationStrategy;
+ var HashLocationStrategy =
+ ng.router.HashLocationStrategy;
+ // #enddocregion ng2import
+
+ // #docregion appimport
+ var HeroComponent = app.HeroComponent;
+ // #enddocregion appimport
+
+ document.addEventListener('DOMContentLoaded', function() {
+ bootstrap(HeroComponent);
+ bootstrap(app.HeroComponentDsl);
+ bootstrap(app.HeroLifecycleComponent);
+ bootstrap(app.HeroDIComponent, [app.DataService]);
+ bootstrap(app.HeroDIInlineComponent, [app.DataService]);
+ bootstrap(app.HeroDIInjectComponent, [
+ ng.core.provide('heroName', {useValue: 'Windstorm'})
+ ]);
+ bootstrap(app.HeroDIInjectComponent2, [
+ ng.core.provide('heroName', {useValue: 'Bombasto'})
+ ]);
+ bootstrap(app.HeroDIInjectAdditionalComponent);
+ bootstrap(app.HeroIOComponent);
+ bootstrap(app.HeroesHostBindingsComponent);
+ bootstrap(app.HeroesQueriesComponent);
+ });
+
+ // #docregion appimport
+})(window.app = window.app || {});
+// #enddocregion appimport
diff --git a/public/docs/_examples/cb-ts-to-js/js/example-config.json b/public/docs/_examples/cb-ts-to-js/js/example-config.json
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/docs/_examples/cb-ts-to-js/js/index.html b/public/docs/_examples/cb-ts-to-js/js/index.html
new file mode 100644
index 0000000000..549d5247ee
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/index.html
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TypeScript to JavaScript
+ Classes and Class Metadata
+ Input and Output Metadata
+ Dependency Injection
+ Host and Query Metadata
+
+
+
+ Loading hero-view...
+ Loading hero-view2...
+ Loading hero-lifecycle...
+
+
+
+ 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...
+
+
+
+ Loading heroes-bindings...
+ Loading heroes-queries...
+
+
+
diff --git a/public/docs/_examples/cb-ts-to-js/js/plnkr.json b/public/docs/_examples/cb-ts-to-js/js/plnkr.json
new file mode 100644
index 0000000000..729230c2d1
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/js/plnkr.json
@@ -0,0 +1,7 @@
+{
+ "description": "TypeScript to JavaScript",
+ "files":[
+ "!**/karma*.*"
+ ],
+ "tags":["cookbook"]
+}
diff --git a/public/docs/_examples/cb-ts-to-js/ts/.gitignore b/public/docs/_examples/cb-ts-to-js/ts/.gitignore
new file mode 100644
index 0000000000..2cb7d2a2e9
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/.gitignore
@@ -0,0 +1 @@
+**/*.js
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
new file mode 100644
index 0000000000..08911a96a2
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/data.service.ts
@@ -0,0 +1,10 @@
+import {Injectable} from 'angular2/core';
+
+@Injectable()
+export class DataService {
+ 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
new file mode 100644
index 0000000000..9f3e37a7d8
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject-additional.component.ts
@@ -0,0 +1,48 @@
+import {
+ Attribute,
+ Component,
+ ElementRef,
+ Inject,
+ Optional,
+ Query,
+ QueryList
+} from 'angular2/core';
+
+// #docregion
+@Component({
+ selector: 'hero-title',
+ template: `
+ {{titlePrefix}} {{title}}
+
+
+ `
+})
+export class TitleComponent {
+ constructor(
+ @Inject('titlePrefix')
+ @Optional()
+ private titlePrefix:string,
+ @Attribute('title')
+ private title:string,
+ @Query('okMsg')
+ private msg:QueryList) {
+ }
+
+ ok() {
+ let msgEl =
+ this.msg.first.nativeElement;
+ msgEl.textContent = 'OK!';
+ }
+}
+// #enddocregion
+
+@Component({
+ selector: 'hero-di-inject-additional',
+ template: `
+
+ `,
+ directives: [TitleComponent]
+})
+export class AppComponent {
+
+}
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
new file mode 100644
index 0000000000..1633598426
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di-inject.component.ts
@@ -0,0 +1,14 @@
+import {Component, Inject} from 'angular2/core';
+
+// #docregion
+@Component({
+ selector: 'hero-di-inject',
+ template: `Hero: {{name}}
`
+})
+export class HeroComponent {
+ constructor(
+ @Inject('heroName')
+ private name:string) {
+ }
+}
+// #enddocregion
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
new file mode 100644
index 0000000000..58f12db09c
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-di.component.ts
@@ -0,0 +1,15 @@
+import {Component} from 'angular2/core';
+import {DataService} from './data.service';
+
+// #docregion
+@Component({
+ selector: 'hero-di',
+ template: `Hero: {{name}}
`
+})
+export class HeroComponent {
+ name:string;
+ constructor(dataService:DataService) {
+ this.name = dataService.getHeroName();
+ }
+}
+// #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
new file mode 100644
index 0000000000..01ce84d8b3
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-io.component.ts
@@ -0,0 +1,56 @@
+import {Component, EventEmitter, Input, Output} from 'angular2/core';
+
+// #docregion
+@Component({
+ selector: 'my-confirm',
+ template: `
+
+
+ `
+})
+export 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
+
+
+@Component({
+ selector: 'hero-io',
+ template: `
+
+
+ OK clicked
+ Cancel clicked
+ `,
+ directives: [ConfirmComponent]
+})
+export class AppComponent {
+ okClicked:boolean;
+ cancelClicked:boolean;
+
+ onOk() {
+ this.okClicked = true;
+ }
+ onCancel() {
+ this.cancelClicked = true;
+ }
+}
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
new file mode 100644
index 0000000000..2a82e9cd20
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero-lifecycle.component.ts
@@ -0,0 +1,19 @@
+// #docplaster
+// #docregion
+import {Component, OnInit}
+ from 'angular2/core';
+ // #enddocregion
+
+@Component({
+ selector: 'hero-lifecycle',
+ template: `Hero: {{name}}
`
+})
+// #docregion
+export class HeroComponent
+ implements OnInit {
+ name:string;
+ ngOnInit() {
+ this.name = 'Windstorm';
+ }
+}
+// #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
new file mode 100644
index 0000000000..1ce2609636
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/hero.component.ts
@@ -0,0 +1,18 @@
+// #docplaster
+// #docregion metadata
+import {Component} from 'angular2/core';
+
+@Component({
+ selector: 'hero-view',
+ template:
+ 'Hero: {{getName()}}
'
+})
+// #docregion appexport
+// #docregion class
+export class HeroComponent {
+ title = 'Hero Detail';
+ getName() {return 'Windstorm';}
+}
+// #enddocregion class
+// #enddocregion appexport
+// #enddocregion metadata
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
new file mode 100644
index 0000000000..6512f41d68
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/heroes-bindings.component.ts
@@ -0,0 +1,28 @@
+import {Component, HostBinding, HostListener} from 'angular2/core';
+
+// #docregion
+@Component({
+ selector: 'heroes-bindings',
+ template: `
+ Tour of Heroes
+
`
+})
+export 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
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
new file mode 100644
index 0000000000..a16906266c
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/heroes-queries.component.ts
@@ -0,0 +1,79 @@
+import {
+ Component,
+ ViewChildren,
+ ContentChild,
+ QueryList,
+ Input
+} from 'angular2/core';
+
+@Component({
+ selector: 'active-label',
+ template: `
+ Active
+ `
+})
+class ActiveLabelComponent {
+ active:boolean;
+
+ activate() {
+ this.active = true;
+ }
+}
+
+// #docregion content
+@Component({
+ selector: '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: `
+
+
+
+
+ `,
+ directives: [
+ HeroComponent,
+ ActiveLabelComponent
+ ]
+})
+export class HeroesQueriesComponent {
+ heroData = [
+ {id: 1, name: 'Windstorm'},
+ {id: 2, name: 'Superman'}
+ ];
+
+ @ViewChildren(HeroComponent)
+ heroCmps:QueryList;
+
+ activate() {
+ this.heroCmps.forEach(
+ (cmp) => cmp.activate()
+ );
+ }
+}
+// #enddocregion view
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
new file mode 100644
index 0000000000..02535f55f8
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/app/main.ts
@@ -0,0 +1,35 @@
+// #docregion ng2import
+import {provide}
+ from 'angular2/core';
+import {bootstrap}
+ from 'angular2/platform/browser';
+import {
+ LocationStrategy,
+ HashLocationStrategy
+} from 'angular2/router';
+// #enddocregion ng2import
+
+// #docregion appimport
+import {HeroComponent}
+ from './hero.component';
+// #enddocregion appimport
+import {HeroComponent as HeroLifecycleComponent} from './hero-lifecycle.component';
+import {HeroComponent as HeroDIComponent} from './hero-di.component';
+import {HeroComponent as HeroDIInjectComponent} from './hero-di-inject.component';
+import {AppComponent as AppDIInjectAdditionalComponent} from './hero-di-inject-additional.component';
+import {AppComponent as AppIOComponent} from './hero-io.component';
+import {HeroesComponent as HeroesHostBindingsComponent} from './heroes-bindings.component';
+import {HeroesQueriesComponent} from './heroes-queries.component';
+
+import {DataService} from './data.service';
+
+bootstrap(HeroComponent);
+bootstrap(HeroLifecycleComponent);
+bootstrap(HeroDIComponent, [DataService]);
+bootstrap(HeroDIInjectComponent, [
+ provide('heroName', {useValue: 'Windstorm'})
+]);
+bootstrap(AppDIInjectAdditionalComponent);
+bootstrap(AppIOComponent);
+bootstrap(HeroesHostBindingsComponent);
+bootstrap(HeroesQueriesComponent);
diff --git a/public/docs/_examples/cb-ts-to-js/ts/example-config.json b/public/docs/_examples/cb-ts-to-js/ts/example-config.json
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/docs/_examples/cb-ts-to-js/ts/index.html b/public/docs/_examples/cb-ts-to-js/ts/index.html
new file mode 100644
index 0000000000..49a1cf88e8
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/index.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TypeScript to JavaScript
+ Classes and Class Metadata
+ Input and Output Metadata
+ Dependency Injection
+ Host and Query Metadata
+
+
+
+ Loading hero-view...
+ Loading hero-lifecycle...
+
+
+
+ Loading hero-io...
+
+
+ Dependency Injection
+ Loading hero-di...
+ Loading hero-di-inject...
+ Loading hero-di-inject-additional...
+
+
+
+ Loading heroes-bindings...
+ Loading heroes-queries...
+
+
+
diff --git a/public/docs/_examples/cb-ts-to-js/ts/plnkr.json b/public/docs/_examples/cb-ts-to-js/ts/plnkr.json
new file mode 100644
index 0000000000..5c7a5acd44
--- /dev/null
+++ b/public/docs/_examples/cb-ts-to-js/ts/plnkr.json
@@ -0,0 +1,8 @@
+{
+ "description": "TypeScript to JavaScript",
+ "files":[
+ "!**/*.d.ts",
+ "!**/*.js"
+ ],
+ "tags":["cookbook"]
+}
diff --git a/public/docs/_examples/component-styles/e2e-spec.js b/public/docs/_examples/component-styles/e2e-spec.js
new file mode 100644
index 0000000000..e667260f99
--- /dev/null
+++ b/public/docs/_examples/component-styles/e2e-spec.js
@@ -0,0 +1,69 @@
+describe('Component Style Tests', function () {
+
+ beforeAll(function () {
+ browser.get('');
+ });
+
+ it('scopes component styles to component view', function() {
+ var componentH1 = element(by.css('hero-app > h1'));
+ var externalH1 = element(by.css('body > h1'));
+
+ expect(componentH1.getCssValue('fontWeight')).toEqual('normal');
+ expect(externalH1.getCssValue('fontWeight')).not.toEqual('normal');
+ });
+
+
+ it('allows styling :host element', function() {
+ var host = element(by.css('hero-details'));
+
+ expect(host.getCssValue('borderWidth')).toEqual('1px');
+ });
+
+ it('supports :host() in function form', function() {
+ var host = element(by.css('hero-details'));
+
+ host.element(by.buttonText('Activate')).click();
+ expect(host.getCssValue('borderWidth')).toEqual('3px');
+ });
+
+ it('allows conditional :host-context() styling', function() {
+ var h2 = element(by.css('hero-details h2'));
+
+ expect(h2.getCssValue('backgroundColor')).toEqual('rgba(238, 238, 255, 1)'); // #eeeeff
+ });
+
+ it('styles both view and content children with /deep/', function() {
+ var viewH3 = element(by.css('hero-team h3'));
+ var contentH3 = element(by.css('hero-controls h3'));
+
+ expect(viewH3.getCssValue('fontStyle')).toEqual('italic');
+ expect(contentH3.getCssValue('fontStyle')).toEqual('italic');
+ });
+
+ it('includes styles loaded with CSS @import', function() {
+ var host = element(by.css('hero-details'));
+
+ expect(host.getCssValue('padding')).toEqual('10px');
+ });
+
+ it('processes template inline styles', function() {
+ var button = element(by.css('hero-controls button'));
+ var externalButton = element(by.css('body > button'));
+ expect(button.getCssValue('backgroundColor')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff
+ expect(externalButton.getCssValue('backgroundColor')).not.toEqual('rgba(255, 255, 255, 1)');
+ });
+
+ it('processes template s', function() {
+ var li = element(by.css('hero-team li:first-child'));
+ var externalLi = element(by.css('body > ul li'));
+
+ expect(li.getCssValue('listStyleType')).toEqual('square');
+ expect(externalLi.getCssValue('listStyleType')).not.toEqual('square');
+ });
+
+ it('supports relative loading with moduleId', function() {
+ var host = element(by.css('quest-summary'));
+ expect(host.getCssValue('color')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff
+ });
+
+});
diff --git a/public/docs/_examples/component-styles/ts/.gitignore b/public/docs/_examples/component-styles/ts/.gitignore
new file mode 100644
index 0000000000..2cb7d2a2e9
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/.gitignore
@@ -0,0 +1 @@
+**/*.js
diff --git a/public/docs/_examples/component-styles/ts/app/hero-app-main.component.ts b/public/docs/_examples/component-styles/ts/app/hero-app-main.component.ts
new file mode 100644
index 0000000000..b127a95b5e
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-app-main.component.ts
@@ -0,0 +1,19 @@
+import {Component, Input} from 'angular2/core';
+import {Hero} from './hero';
+import {HeroDetailsComponent} from './hero-details.component';
+import {HeroControlsComponent} from './hero-controls.component';
+import {QuestSummaryComponent} from './quest-summary.component';
+
+@Component({
+ selector: 'hero-app-main',
+ template: `
+
+
+
+
+ `,
+ directives: [HeroDetailsComponent, HeroControlsComponent, QuestSummaryComponent]
+})
+export class HeroAppMainComponent {
+ @Input() hero: Hero;
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero-app.component.ts b/public/docs/_examples/component-styles/ts/app/hero-app.component.ts
new file mode 100644
index 0000000000..8eb5c9116c
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-app.component.ts
@@ -0,0 +1,25 @@
+import {Component, HostBinding} from 'angular2/core';
+import {Hero} from './hero';
+import {HeroAppMainComponent} from './hero-app-main.component';
+
+// #docregion
+@Component({
+ selector: 'hero-app',
+ template: `
+ Tour of Heroes
+ `,
+ styles: ['h1 { font-weight: normal; }'],
+ directives: [HeroAppMainComponent]
+})
+// #enddocregion
+export class HeroAppComponent {
+ hero = new Hero(
+ 'Human Torch',
+ ['Mister Fantastic', 'Invisible Woman', 'Thing']
+ )
+
+ @HostBinding('class') get themeClass() {
+ return 'theme-light';
+ }
+
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero-controls.component.ts b/public/docs/_examples/component-styles/ts/app/hero-controls.component.ts
new file mode 100644
index 0000000000..fb674d0a63
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-controls.component.ts
@@ -0,0 +1,26 @@
+import {Component, Input} from 'angular2/core';
+import {Hero} from './hero';
+
+// #docregion inlinestyles
+@Component({
+ selector: 'hero-controls',
+ template: `
+
+ Controls
+
+ `
+})
+// #enddocregion inlinestyles
+export class HeroControlsComponent {
+
+ @Input() hero: Hero;
+
+ activate() {
+ this.hero.active = true;
+ }
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero-details-box.css b/public/docs/_examples/component-styles/ts/app/hero-details-box.css
new file mode 100644
index 0000000000..f240073005
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-details-box.css
@@ -0,0 +1,3 @@
+:host {
+ padding: 10px;
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero-details.component.css b/public/docs/_examples/component-styles/ts/app/hero-details.component.css
new file mode 100644
index 0000000000..fd938ca55c
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-details.component.css
@@ -0,0 +1,28 @@
+/* #docregion import */
+@import 'hero-details-box.css';
+/* #enddocregion import */
+
+/* #docregion host */
+:host {
+ display: block;
+ border: 1px solid black;
+}
+/* #enddocregion host */
+
+/* #docregion hostfunction */
+:host(.active) {
+ border-width: 3px;
+}
+/* #enddocregion hostfunction */
+
+/* #docregion hostcontext */
+:host-context(.theme-light) h2 {
+ background-color: #eef;
+}
+/* #enddocregion hostcontext */
+
+/* #docregion deep */
+:host /deep/ h3 {
+ font-style: italic;
+}
+/* #enddocregion deep */
diff --git a/public/docs/_examples/component-styles/ts/app/hero-details.component.ts b/public/docs/_examples/component-styles/ts/app/hero-details.component.ts
new file mode 100644
index 0000000000..344063a543
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-details.component.ts
@@ -0,0 +1,20 @@
+import {Component, Input} from 'angular2/core';
+import {Hero} from './hero';
+import {HeroTeamComponent} from './hero-team.component';
+
+// #docregion styleurls
+@Component({
+ selector: 'hero-details',
+ template: `
+ {{hero.name}}
+
+
+ `,
+ styleUrls: ['app/hero-details.component.css'],
+ directives: [HeroTeamComponent]
+})
+export class HeroDetailsComponent {
+// #enddocregion styleurls
+
+ @Input() hero:Hero;
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero-team.component.css b/public/docs/_examples/component-styles/ts/app/hero-team.component.css
new file mode 100644
index 0000000000..b87679886b
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-team.component.css
@@ -0,0 +1,3 @@
+li {
+ list-style-type: square;
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero-team.component.ts b/public/docs/_examples/component-styles/ts/app/hero-team.component.ts
new file mode 100644
index 0000000000..78885ff1ea
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero-team.component.ts
@@ -0,0 +1,19 @@
+import {Component, Input} from 'angular2/core';
+import {Hero} from './hero';
+
+// #docregion stylelink
+@Component({
+ selector: 'hero-team',
+ template: `
+
+ Team
+ `
+})
+// #enddocregion stylelink
+export class HeroTeamComponent {
+ @Input() hero: Hero;
+}
diff --git a/public/docs/_examples/component-styles/ts/app/hero.ts b/public/docs/_examples/component-styles/ts/app/hero.ts
new file mode 100644
index 0000000000..8b58c8a8f8
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/hero.ts
@@ -0,0 +1,7 @@
+export class Hero {
+ active:boolean;
+
+ constructor(public name:string,
+ public team:string[]) {
+ }
+}
diff --git a/public/docs/_examples/component-styles/ts/app/main.ts b/public/docs/_examples/component-styles/ts/app/main.ts
new file mode 100644
index 0000000000..a9194f16f3
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/main.ts
@@ -0,0 +1,4 @@
+import {bootstrap} from 'angular2/platform/browser';
+import {HeroAppComponent} from './hero-app.component';
+
+bootstrap(HeroAppComponent);
diff --git a/public/docs/_examples/component-styles/ts/app/quest-summary.component.css b/public/docs/_examples/component-styles/ts/app/quest-summary.component.css
new file mode 100644
index 0000000000..207fa981dd
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/quest-summary.component.css
@@ -0,0 +1,5 @@
+:host {
+ display: block;
+ background-color: green;
+ color: white;
+}
diff --git a/public/docs/_examples/component-styles/ts/app/quest-summary.component.html b/public/docs/_examples/component-styles/ts/app/quest-summary.component.html
new file mode 100644
index 0000000000..abf63c2542
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/quest-summary.component.html
@@ -0,0 +1 @@
+No quests in progress
diff --git a/public/docs/_examples/component-styles/ts/app/quest-summary.component.ts b/public/docs/_examples/component-styles/ts/app/quest-summary.component.ts
new file mode 100644
index 0000000000..daea1a26b9
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/app/quest-summary.component.ts
@@ -0,0 +1,32 @@
+// #docplaster
+import {Component, ViewEncapsulation} from 'angular2/core';
+
+// #docregion
+// Let TypeScript know about the special SystemJS __moduleName variable
+declare var __moduleName: string;
+// #enddocregion
+// moduleName is not set in some module loaders; set it explicitly
+if (!__moduleName) {
+ __moduleName = `http://${location.host}/${location.pathname}/app/`;
+}
+console.log(`The __moduleName is ${__moduleName} `);
+// #docregion
+
+@Component({
+ moduleId: __moduleName,
+ selector: 'quest-summary',
+ // #docregion urls
+ templateUrl: 'quest-summary.component.html',
+ styleUrls: ['quest-summary.component.css']
+ // #enddocregion urls
+// #enddocregion
+/*
+ // #docregion encapsulation.native
+ // warning: few browsers support shadow DOM encapsulation at this time
+ encapsulation: ViewEncapsulation.Native
+ // #enddocregion encapsulation.native
+*/
+// #docregion
+})
+export class QuestSummaryComponent { }
+// #enddocregion
diff --git a/public/docs/_examples/component-styles/ts/example-config.json b/public/docs/_examples/component-styles/ts/example-config.json
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/docs/_examples/component-styles/ts/index.html b/public/docs/_examples/component-styles/ts/index.html
new file mode 100644
index 0000000000..58098522ff
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/index.html
@@ -0,0 +1,40 @@
+
+
+
+ Component Styles
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ External H1 Title for E2E test
+
+
+
+ - External list for E2E test
+
+
+
+
diff --git a/public/docs/_examples/component-styles/ts/plnkr.json b/public/docs/_examples/component-styles/ts/plnkr.json
new file mode 100644
index 0000000000..fb313556fc
--- /dev/null
+++ b/public/docs/_examples/component-styles/ts/plnkr.json
@@ -0,0 +1,9 @@
+{
+ "description": "Component Styles",
+ "files": [
+ "!**/*.d.ts",
+ "!**/*.js",
+ "!**/*.native.*"
+ ],
+ "tags": ["CSS"]
+}
diff --git a/public/docs/_examples/dependency-injection/dart/.analysis_options b/public/docs/_examples/dependency-injection/dart/.analysis_options
new file mode 100644
index 0000000000..d8c582e96f
--- /dev/null
+++ b/public/docs/_examples/dependency-injection/dart/.analysis_options
@@ -0,0 +1,16 @@
+# Supported lint rules and documentation: http://dart-lang.github.io/linter/lints/
+linter:
+ rules:
+ - always_declare_return_types
+ - camel_case_types
+ - empty_constructor_bodies
+ - annotate_overrides
+ - avoid_init_to_null
+ - constant_identifier_names
+ - one_member_abstracts
+ - slash_for_doc_comments
+ - sort_constructors_first
+ - unnecessary_brace_in_string_interp
+
+analyzer:
+ # strong-mode: true
diff --git a/public/docs/_examples/dependency-injection/dart/lib/app_component.dart b/public/docs/_examples/dependency-injection/dart/lib/app_component.dart
index 4e01554a42..1a9e4f075b 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/app_component.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/app_component.dart
@@ -1,15 +1,14 @@
// #docplaster
-
// #docregion
-
// #docregion imports
import 'package:angular2/core.dart';
+
+import 'app_config.dart';
import 'car/car_component.dart';
import 'heroes/heroes_component.dart';
-import 'app_config.dart';
import 'logger_service.dart';
import 'user_service.dart';
-
+//PENDING: check whether we intend to hide injector_component.dart & providers_component.dart; if so, change docregion name?
// #enddocregion imports
import 'injector_component.dart';
import 'providers_component.dart';
@@ -17,33 +16,39 @@ import 'providers_component.dart';
@Component(
selector: 'my-app',
template: '''
- {{title}}
-
-
-
- User
-
- {{userInfo}}
-
-
-
-
- ''',
- directives: const [CarComponent, HeroesComponent, InjectorComponent, ProvidersComponent],
+
{{title}}
+
+
+
+ User
+
+ {{userInfo}}
+
+
+
+ ''',
+ directives: const [
+ CarComponent,
+ HeroesComponent,
+ InjectorComponent,
+ ProvidersComponent
+ ],
// #docregion providers
- providers: const [Logger, UserService, const Provider(Config, useValue: CONFIG)]
+ providers: const [
+ Logger,
+ UserService,
+ const Provider(AppConfig, useValue: config1)]
// #enddocregion providers
- )
+)
class AppComponent {
- UserService _userService;
- String title;
+ final UserService _userService;
+ final String title;
//#docregion ctor
- AppComponent(Config config, this._userService) {
- title = config.title;
- }
-
+ AppComponent(AppConfig config, this._userService)
+ : title = config.title;
// #enddocregion ctor
+
bool get isAuthorized {
return user.isAuthorized;
}
@@ -56,8 +61,7 @@ class AppComponent {
return _userService.user;
}
- String get userInfo {
- return 'Current user, ${user.name}, is ${isAuthorized ? "" : "not"} authorized. ';
- }
+ String get userInfo => 'Current user, ${user.name}, is'
+ '${isAuthorized ? "" : " not"} authorized. ';
}
// #enddocregion
diff --git a/public/docs/_examples/dependency-injection/dart/lib/app_component_1.dart b/public/docs/_examples/dependency-injection/dart/lib/app_component_1.dart
index 7c3b7b9808..2466b4894b 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/app_component_1.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/app_component_1.dart
@@ -2,19 +2,19 @@
// #docregion
import 'package:angular2/core.dart';
+
import 'car/car_component.dart';
import 'heroes/heroes_component_1.dart';
@Component(
selector: 'my-app',
template: '''
-
{{title}}
-
-
- ''',
+ {{title}}
+
+ ''',
directives: const [CarComponent, HeroesComponent])
class AppComponent {
- var title = 'Dependency Injection';
+ final String title = 'Dependency Injection';
}
// #enddocregion
diff --git a/public/docs/_examples/dependency-injection/dart/lib/app_component_2.dart b/public/docs/_examples/dependency-injection/dart/lib/app_component_2.dart
index 7bf4249ee2..4463b7c59c 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/app_component_2.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/app_component_2.dart
@@ -2,34 +2,32 @@
// #docregion imports
import 'package:angular2/core.dart';
+
+import 'app_config.dart';
import 'car/car_component.dart';
import 'heroes/heroes_component_1.dart';
-import 'app_config.dart';
import 'logger_service.dart';
-
// #enddocregion imports
+
@Component(
selector: 'my-app',
template: '''
- {{title}}
-
-
- ''',
+ {{title}}
+
+ ''',
directives: const [
CarComponent,
HeroesComponent
],
providers: const [
Logger,
- // #docregion provider-config
- const Provider('app.config', useValue: CONFIG)
+ const Provider(AppConfig, useValue: config1)
])
class AppComponent {
- String title;
+ final String title;
// #docregion ctor
- AppComponent(@Inject('app.config') Config config) {
- title = config.title;
- }
+ AppComponent(AppConfig config)
+ : title = config.title;
+ // #enddocregion
}
-// #enddocregion
diff --git a/public/docs/_examples/dependency-injection/dart/lib/app_config.dart b/public/docs/_examples/dependency-injection/dart/lib/app_config.dart
index 8fc877f188..7785eff1b4 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/app_config.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/app_config.dart
@@ -1,29 +1,17 @@
-//#docregion
-
+// #docregion
// #docregion token
import 'package:angular2/core.dart';
-const APP_CONFIG = const OpaqueToken('app.config');
-// #enddocregion token
-
-//#docregion config
-abstract class Config {
- final String apiEndpoint;
+//#docregion const-class
+@Injectable()
+class AppConfig {
+ final apiEndpoint;
final String title;
- const Config({this.apiEndpoint, this.title});
+ const AppConfig(this.apiEndpoint, this.title);
}
+//#enddocregion const-class
-class ConfigImpl implements Config {
- final String apiEndpoint;
- final String title;
-
- const ConfigImpl({this.apiEndpoint, this.title});
-}
-
-const CONFIG = const ConfigImpl(apiEndpoint: 'api.heroes.com', title: 'Dependency Injection');
-//#enddocregion config
-
-//#docregion config-hash
-const CONFIG_HASH = const {'apiEndpoint': 'api.heroes.com', 'title': 'Dependency Injection'};
-//#enddocregion config-hash
+//#docregion const-object
+const config1 = const AppConfig('api.heroes.com', 'Dependency Injection');
+//#enddocregion const-object
diff --git a/public/docs/_examples/dependency-injection/dart/lib/car/car.dart b/public/docs/_examples/dependency-injection/dart/lib/car/car.dart
index 4c8d1025e7..cacd0d9b69 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/car/car.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/car/car.dart
@@ -1,13 +1,14 @@
// #docregion
-
import 'package:angular2/core.dart';
+@Injectable()
// #docregion engine
class Engine {
- int cylinders = 4;
+ final int cylinders = 4;
}
// #enddocregion engine
+@Injectable()
// #docregion tires
class Tires {
String make = 'Flintstone';
@@ -18,8 +19,8 @@ class Tires {
@Injectable()
class Car {
//#docregion car-ctor
- Engine engine;
- Tires tires;
+ final Engine engine;
+ final Tires tires;
String description = 'DI';
Car(this.engine, this.tires);
@@ -27,6 +28,7 @@ class Car {
// #enddocregion car-ctor
// Method using the engine and tires
- String drive() => '$description car with ${engine.cylinders} cylinders and ${tires.make} tires.';
+ String drive() => '$description car with ${engine.cylinders} cylinders'
+ ' and ${tires.make} tires.';
}
// #enddocregion car
diff --git a/public/docs/_examples/dependency-injection/dart/lib/car/car_component.dart b/public/docs/_examples/dependency-injection/dart/lib/car/car_component.dart
index e8e3ccc0e0..b7e663b019 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/car/car_component.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/car/car_component.dart
@@ -1,29 +1,29 @@
// #docregion
-
import 'package:angular2/core.dart';
+
import 'car.dart';
-import 'car_no_di.dart' as carNoDi;
-import 'car_factory.dart';
import 'car_creations.dart' as carCreations;
+import 'car_factory.dart';
import 'car_injector.dart';
+import 'car_no_di.dart' as carNoDi;
@Component(
selector: 'my-car',
template: '''
- Cars
- {{car.drive()}}
- {{noDiCar.drive()}}
- {{injectorCar.drive()}}
- {{factoryCar.drive()}}
- {{simpleCar.drive()}}
- {{superCar.drive()}}
- {{testCar.drive()}}
- ''',
+ Cars
+ {{car.drive()}}
+ {{noDiCar.drive()}}
+ {{injectorCar.drive()}}
+ {{factoryCar.drive()}}
+ {{simpleCar.drive()}}
+ {{superCar.drive()}}
+ {{testCar.drive()}}
''',
providers: const [Car, Engine, Tires])
class CarComponent {
- Car car;
+ final Car car;
+
+ CarComponent(this.car);
- CarComponent(this.car) {}
Car factoryCar = (new CarFactory()).createCar();
Car injectorCar = useInjector();
carNoDi.Car noDiCar = new carNoDi.Car();
diff --git a/public/docs/_examples/dependency-injection/dart/lib/car/car_creations.dart b/public/docs/_examples/dependency-injection/dart/lib/car/car_creations.dart
index 33dfa05828..d0e6be3c1c 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/car/car_creations.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/car/car_creations.dart
@@ -1,12 +1,10 @@
-// Examples with car and engine variations
-
// #docplaster
+// Examples with car and engine variations
import 'car.dart';
///////// example 1 ////////////
Car simpleCar() {
//#docregion car-ctor-instantiation
-
// Simple car with 4 cylinders and Flintstone tires.
var car = new Car(new Engine(), new Tires());
//#enddocregion car-ctor-instantiation
@@ -17,19 +15,18 @@ Car simpleCar() {
//#docregion car-ctor-instantiation-with-param
class Engine2 implements Engine {
- int cylinders;
+ final int cylinders;
Engine2(this.cylinders);
}
-
//#enddocregion car-ctor-instantiation-with-param
-Car superCar() {
- //#docregion car-ctor-instantiation-with-param
- // Super car with 12 cylinders and Flintstone tires.
- var bigCylinders = 12;
- var car = new Car(new Engine2(bigCylinders), new Tires());
- //#enddocregion car-ctor-instantiation-with-param
+Car superCar() {
+//#docregion car-ctor-instantiation-with-param
+// Super car with 12 cylinders and Flintstone tires.
+var bigCylinders = 12;
+var car = new Car(new Engine2(bigCylinders), new Tires());
+//#enddocregion car-ctor-instantiation-with-param
car.description = 'Super';
return car;
}
@@ -37,7 +34,7 @@ Car superCar() {
//#docregion car-ctor-instantiation-with-mocks
class MockEngine extends Engine {
- int cylinders = 8;
+ final int cylinders = 8;
}
class MockTires extends Tires {
@@ -46,11 +43,10 @@ class MockTires extends Tires {
//#enddocregion car-ctor-instantiation-with-mocks
Car testCar() {
- //#docregion car-ctor-instantiation-with-mocks
-
- // Test car with 8 cylinders and YokoGoodStone tires.
- var car = new Car(new MockEngine(), new MockTires());
- //#enddocregion car-ctor-instantiation-with-mocks
+//#docregion car-ctor-instantiation-with-mocks
+// Test car with 8 cylinders and YokoGoodStone tires.
+var car = new Car(new MockEngine(), new MockTires());
+//#enddocregion car-ctor-instantiation-with-mocks
car.description = 'Test';
return car;
}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/car/car_factory.dart b/public/docs/_examples/dependency-injection/dart/lib/car/car_factory.dart
index 76b8a4cc63..7610e28b14 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/car/car_factory.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/car/car_factory.dart
@@ -1,15 +1,13 @@
// #docregion
-
import 'car.dart';
+// BAD pattern!
class CarFactory {
Car createCar() {
- var car = new Car(createEngine(), createTires());
- car.description = 'Factory';
- return car;
+ return new Car(createEngine(), createTires())
+ ..description = 'Factory';
}
Engine createEngine() => new Engine();
-
Tires createTires() => new Tires();
}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/car/car_injector.dart b/public/docs/_examples/dependency-injection/dart/lib/car/car_injector.dart
index 1dbadd9fab..d3da37a9e7 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/car/car_injector.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/car/car_injector.dart
@@ -1,9 +1,9 @@
// #docplaster
-
//#docregion
import 'package:angular2/core.dart';
-import 'car.dart';
+
import '../logger_service.dart';
+import 'car.dart';
//#docregion injector
Car useInjector() {
@@ -24,8 +24,8 @@ Car useInjector() {
//#docregion injector-call
var car = injector.get(Car);
//#enddocregion injector-call
-
//#enddocregion injector-create-and-call
+
car.description = 'Injector';
var logger = injector.get(Logger);
logger.log('Injector car.drive() said: ' + car.drive());
diff --git a/public/docs/_examples/dependency-injection/dart/lib/car/car_no_di.dart b/public/docs/_examples/dependency-injection/dart/lib/car/car_no_di.dart
index 32972c3dc1..86a4177b2d 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/car/car_no_di.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/car/car_no_di.dart
@@ -13,10 +13,10 @@ class Car {
engine = new Engine();
tires = new Tires();
}
-
//#enddocregion car-ctor
// Method using the engine and tires
- drive() => '$description car with ${engine.cylinders} cylinders and ${tires.make} tires.';
+ String drive() => '$description car with '
+ '${engine.cylinders} cylinders and ${tires.make} tires.';
}
//#enddocregion car
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero.dart
index ea10276b7c..2a76844f9c 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero.dart
@@ -1,5 +1,4 @@
// #docregion
-
class Hero {
num id;
String name;
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component.dart
index c4eeb14f1b..0c79b2f600 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component.dart
@@ -1,19 +1,18 @@
// #docregion
-
import 'package:angular2/core.dart';
+
import 'hero.dart';
import 'hero_service.dart';
@Component(
selector: 'hero-list',
template: '''
-
- {{hero.id}} - {{hero.name}}
- ({{hero.isSecret ? \'secret\' : \'public\'}})
-
- ''')
+
+ {{hero.id}} - {{hero.name}}
+ ({{hero.isSecret ? 'secret' : 'public'}})
+
''')
class HeroListComponent {
- List heroes;
+ final List heroes;
//#docregion ctor-signature
HeroListComponent(HeroService heroService) : heroes = heroService.getHeroes();
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_1.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_1.dart
index 3aeef5aefb..366cf570b0 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_1.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_1.dart
@@ -1,16 +1,15 @@
// #docregion
-
import 'package:angular2/core.dart';
+
import 'hero.dart';
import 'mock_heroes.dart';
@Component(
selector: 'hero-list',
template: '''
-
- {{hero.id}} - {{hero.name}}
-
- ''')
+
+ {{hero.id}} - {{hero.name}}
+
''')
class HeroListComponent {
- List heroes = HEROES;
+ final List heroes = HEROES;
}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_2.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_2.dart
index 2b76419505..637ca74b00 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_2.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_2.dart
@@ -1,20 +1,20 @@
// #docregion
-
import 'package:angular2/core.dart';
+
import 'hero.dart';
import 'hero_service.dart';
@Component(
selector: 'hero-list',
template: '''
-
- {{hero.id}} - {{hero.name}}
-
- ''')
+
+ {{hero.id}} - {{hero.name}}
+
''')
class HeroListComponent {
- List heroes;
+ final List heroes;
//#docregion ctor
- HeroListComponent(HeroService heroService) : heroes = heroService.getHeroes();
+ HeroListComponent(HeroService heroService)
+ : heroes = heroService.getHeroes();
//#enddocregion ctor
}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service.dart
index 2dda48cb70..59074e3cd4 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service.dart
@@ -1,22 +1,24 @@
// #docregion
-
import 'package:angular2/core.dart';
+
+import '../logger_service.dart';
import 'hero.dart';
import 'mock_heroes.dart';
-import '../logger_service.dart';
@Injectable()
class HeroService {
// #docregion internals
- Logger _logger;
- bool _isAuthorized;
+ final Logger _logger;
+ final bool _isAuthorized;
HeroService(this._logger, this._isAuthorized);
List getHeroes() {
var auth = _isAuthorized ? 'authorized' : 'unauthorized';
- _logger.log('Getting heroes for ${auth} user.');
- return HEROES.where((hero) => _isAuthorized || !hero.isSecret).toList();
+ _logger.log('Getting heroes for $auth user.');
+ return HEROES
+ .where((hero) => _isAuthorized || !hero.isSecret)
+ .toList();
}
// #enddocregion internals
}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_1.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_1.dart
index 7ee6a642b4..f400d86fc4 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_1.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_1.dart
@@ -1,5 +1,4 @@
// #docregion
-
import 'hero.dart';
import 'mock_heroes.dart';
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_2.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_2.dart
index 25146a76f9..badd8f548e 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_2.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_2.dart
@@ -1,13 +1,13 @@
// #docregion
-
import 'package:angular2/core.dart';
+
+import '../logger_service.dart';
import 'hero.dart';
import 'mock_heroes.dart';
-import '../logger_service.dart';
@Injectable()
class HeroService {
- Logger _logger;
+ final Logger _logger;
//#docregion ctor
HeroService(this._logger);
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_provider.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_provider.dart
index b783f0edc5..7e457e2db9 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_provider.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_provider.dart
@@ -1,16 +1,18 @@
// #docregion
-
import 'package:angular2/core.dart';
-import 'hero_service.dart';
+
import '../logger_service.dart';
import '../user_service.dart';
+import 'hero_service.dart';
// #docregion factory
+@Injectable()
heroServiceFactory(Logger logger, UserService userService) =>
new HeroService(logger, userService.user.isAuthorized);
// #enddocregion factory
// #docregion provider
-const heroServiceProvider =
- const Provider(HeroService, useFactory: heroServiceFactory, deps: const [Logger, UserService]);
+const heroServiceProvider = const Provider(HeroService,
+ useFactory: heroServiceFactory,
+ deps: const [Logger, UserService]);
// #enddocregion provider
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component.dart
index 45e310cd30..d90871de73 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component.dart
@@ -1,15 +1,14 @@
// #docregion
-
import 'package:angular2/core.dart';
+
import 'hero_list_component.dart';
import 'hero_service_provider.dart';
@Component(
selector: 'my-heroes',
template: '''
- Heroes
-
- ''',
+ Heroes
+ ''',
providers: const [heroServiceProvider],
directives: const [HeroListComponent])
class HeroesComponent {}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component_1.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component_1.dart
index 80d7ad8f2e..19cde705ce 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component_1.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/heroes_component_1.dart
@@ -1,20 +1,18 @@
// #docplaster
-
// #docregion
// #docregion v1
import 'package:angular2/core.dart';
-import 'hero_list_component.dart';
+import 'hero_list_component.dart';
// #enddocregion v1
import 'hero_service.dart';
-
// #docregion v1
+
@Component(
selector: 'my-heroes',
template: '''
- Heroes
-
- ''',
+ Heroes
+ ''',
// #enddocregion v1
// #docregion providers
providers: const [HeroService],
diff --git a/public/docs/_examples/dependency-injection/dart/lib/heroes/mock_heroes.dart b/public/docs/_examples/dependency-injection/dart/lib/heroes/mock_heroes.dart
index 9f49bf208c..2501f92081 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/heroes/mock_heroes.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/heroes/mock_heroes.dart
@@ -1,5 +1,4 @@
// #docregion
-
import 'hero.dart';
List HEROES = [
diff --git a/public/docs/_examples/dependency-injection/dart/lib/injector_component.dart b/public/docs/_examples/dependency-injection/dart/lib/injector_component.dart
index 24e1598f13..ecc85f9c39 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/injector_component.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/injector_component.dart
@@ -2,21 +2,21 @@
//#docregion
import 'package:angular2/core.dart';
+
import 'car/car.dart';
+import 'heroes/hero.dart';
import 'heroes/hero_service.dart';
import 'heroes/hero_service_provider.dart';
import 'logger_service.dart';
-import 'package:dependency_injection/heroes/hero.dart';
//#docregion injector
@Component(
selector: 'my-injectors',
template: '''
- Other Injections
- {{car.drive()}}
- {{hero.name}}
- {{rodent}}
- ''',
+ Other Injections
+ {{car.drive()}}
+ {{hero.name}}
+ {{rodent}}
''',
providers: const [
Car,
Engine,
@@ -25,20 +25,9 @@ import 'package:dependency_injection/heroes/hero.dart';
Logger
])
class InjectorComponent {
- Injector _injector;
-
- InjectorComponent(this._injector) {
- car = _injector.get(Car);
- heroService = _injector.get(HeroService);
- hero = heroService.getHeroes()[0];
- }
-
+ final Injector _injector;
Car car;
-
- //#docregion get-hero-service
HeroService heroService;
-
- //#enddocregion get-hero-service
Hero hero;
String get rodent {
@@ -48,6 +37,14 @@ class InjectorComponent {
}
return "R.O.U.S.'s? I don't think they exist!";
}
+
+ InjectorComponent(this._injector) {
+ car = _injector.get(Car);
+ //#docregion get-hero-service
+ heroService = _injector.get(HeroService);
+ //#enddocregion get-hero-service
+ hero = heroService.getHeroes()[0];
+ }
}
//#enddocregion injector
diff --git a/public/docs/_examples/dependency-injection/dart/lib/logger_service.dart b/public/docs/_examples/dependency-injection/dart/lib/logger_service.dart
index 452daefd22..38b4450f25 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/logger_service.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/logger_service.dart
@@ -1,5 +1,4 @@
// #docregion
-
import 'package:angular2/core.dart';
@Injectable()
diff --git a/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart b/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart
index 83d461deb2..34a1c82f3e 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart
@@ -2,22 +2,19 @@
//#docplaster
import 'package:angular2/core.dart';
+
import 'app_config.dart';
import 'heroes/hero_service_provider.dart';
import 'heroes/hero_service.dart';
import 'logger_service.dart';
import 'user_service.dart';
-// #docregion import-optional
-import 'package:angular2/core.dart' show Optional;
-// #enddocregion import-optional
-
-const template = '{{log}}';
-
-//////////////////////////////////////////
-@Component(selector: 'provider-1', template: '{{log}}', providers:
+@Component(
+ selector: 'provider-1',
+ template: '{{log}}',
+ providers:
//#docregion providers-1
-const [Logger]
+ const [Logger]
//#enddocregion providers-1
)
class ProviderComponent1 {
@@ -25,14 +22,16 @@ class ProviderComponent1 {
ProviderComponent1(Logger logger) {
logger.log('Hello from logger provided with Logger class');
- log = logger.logs[0];
+ log = logger.logs.last;
}
}
-//////////////////////////////////////////
-@Component(selector: 'provider-2', template: '{{log}}', providers:
+@Component(
+ selector: 'provider-2',
+ template: '{{log}}',
+ providers:
//#docregion providers-2
-const [const Provider(Logger, useClass: Logger)]
+ const [const Provider(Logger, useClass: Logger)]
//#enddocregion providers-2
)
class ProviderComponent2 {
@@ -40,36 +39,32 @@ class ProviderComponent2 {
ProviderComponent2(Logger logger) {
logger.log('Hello from logger provided with Provider class and useClass');
- log = logger.logs[0];
+ log = logger.logs.last;
}
}
-//////////////////////////////////////////
@Component(
selector: 'provider-3',
template: '{{log}}',
- providers: const [const Provider(Logger, useClass: Logger)]
-/*
-//#docregion providers-3
- const [provide(Logger, useClass: Logger)]
-//#enddocregion providers-3
-*/
-)
+ providers: const [const Provider(Logger, useClass: Logger)])
class ProviderComponent3 {
String log;
ProviderComponent3(Logger logger) {
logger.log('Hello from logger provided with useClass');
- log = logger.logs[0];
+ log = logger.logs.last;
}
}
-//////////////////////////////////////////
+@Injectable()
class BetterLogger extends Logger {}
-@Component(selector: 'provider-4', template: '{{log}}', providers:
+@Component(
+ selector: 'provider-4',
+ template: '{{log}}',
+ providers:
//#docregion providers-4
-const [const Provider(Logger, useClass: BetterLogger)]
+ const [const Provider(Logger, useClass: BetterLogger)]
//#enddocregion providers-4
)
class ProviderComponent4 {
@@ -77,31 +72,32 @@ class ProviderComponent4 {
ProviderComponent4(Logger logger) {
logger.log('Hello from logger provided with useClass:BetterLogger');
- log = logger.logs[0];
+ log = logger.logs.last;
}
}
-//////////////////////////////////////////
// #docregion EvenBetterLogger
@Injectable()
class EvenBetterLogger implements Logger {
- UserService _userService;
-
- List logs = [];
+ final UserService _userService;
+ @override List logs = [];
EvenBetterLogger(this._userService);
- log(String message) {
- message = 'Message to ${ _userService.user.name}: ${ message}.';
- print(message);
- logs.add(message);
+ @override void log(String message) {
+ var msg = 'Message to ${_userService.user.name}: $message.';
+ print(msg);
+ logs.add(msg);
}
}
// #enddocregion EvenBetterLogger
-@Component(selector: 'provider-5', template: '{{log}}', providers:
+@Component(
+ selector: 'provider-5',
+ template: '{{log}}',
+ providers:
//#docregion providers-5
-const [UserService, const Provider(Logger, useClass: EvenBetterLogger)]
+ const [UserService, const Provider(Logger, useClass: EvenBetterLogger)]
//#enddocregion providers-5
)
class ProviderComponent5 {
@@ -109,29 +105,30 @@ class ProviderComponent5 {
ProviderComponent5(Logger logger) {
logger.log('Hello from EvenBetterlogger');
- log = logger.logs[0];
+ log = logger.logs.last;
}
}
-//////////////////////////////////////////
+@Injectable()
class NewLogger extends Logger implements OldLogger {}
class OldLogger {
List logs = [];
- log(String message) {
+ void log(String message) {
throw new Exception('Should not call the old logger!');
}
}
-@Component(selector: 'provider-6a', template: '{{log}}', providers:
-//#docregion providers-6a
-const [
- NewLogger,
-// Not aliased! Creates two instances of `NewLogger`
- const Provider(OldLogger, useClass: NewLogger)
-]
-//#enddocregion providers-6a
+@Component(
+ selector: 'provider-6a',
+ template: '{{log}}',
+ providers:
+ //#docregion providers-6a
+ const [NewLogger,
+ // Not aliased! Creates two instances of `NewLogger`
+ const Provider(OldLogger, useClass: NewLogger)]
+ //#enddocregion providers-6a
)
class ProviderComponent6a {
String log;
@@ -144,18 +141,22 @@ class ProviderComponent6a {
// The newLogger wasn't called so no logs[]
// display the logs of the oldLogger.
- log = newLogger.logs == null || newLogger.logs.isEmpty ? oldLogger.logs[0] : newLogger.logs[0];
+ log = newLogger.logs == null || newLogger.logs.isEmpty
+ ? oldLogger.logs[0]
+ : newLogger.logs[0];
}
}
-@Component(selector: 'provider-6b', template: '{{log}}', providers:
-//#docregion providers-6b
-const [
- NewLogger,
-// Alias OldLogger w/ reference to NewLogger
- const Provider(OldLogger, useExisting: NewLogger)
-//#enddocregion providers-6b
-])
+@Component(
+ selector: 'provider-6b',
+ template: '{{log}}',
+ providers:
+ //#docregion providers-6b
+ const [NewLogger,
+ // Alias OldLogger with reference to NewLogger
+ const Provider(OldLogger, useExisting: NewLogger)]
+ //#enddocregion providers-6b
+)
class ProviderComponent6b {
String log;
@@ -167,43 +168,46 @@ class ProviderComponent6b {
log = newLogger.logs[0];
}
}
-//////////////////////////////////////////
-// #docregion silent-logger
+// #docregion opaque-token
+const loggerPrefix = const OpaqueToken('Logger prefix');
+// #enddocregion opaque-token
-// An object in the shape of the logger service
-class SilentLogger /*implements Logger*/ {
- const SilentLogger({this.logs});
+// #docregion configurable-logger
+@Injectable()
+class ConfigurableLogger extends Logger {
+ final String _prefix;
- final List logs;
+// #docregion use-opaque-token
+ ConfigurableLogger(@Inject(loggerPrefix) this._prefix);
+// #enddocregion use-opaque-token
- log(String message) {}
+ @override
+ void log(String msg) {
+ super.log('$_prefix: $msg');
+ }
}
+// #enddocregion configurable-logger
-const silentLogger = const SilentLogger(
- logs: const ['Silent logger says "Shhhhh!". Provided via "useValue"']);
-// #enddocregion silent-logger
-
-@Component(selector: 'provider-7', template: '{{log}}', providers:
+@Component(selector: 'provider-7', template: '{{message}}',
//#docregion providers-7
-const [const Provider(SilentLogger, useValue: silentLogger)]
+providers: const [
+ const Provider(Logger, useClass: ConfigurableLogger),
+//#docregion providers-usevalue
+ const Provider(loggerPrefix, useValue: 'Testing')
+//#enddocregion providers-usevalue
+]
//#enddocregion providers-7
-/*
-//#docregion providers-7-unchecked
-const [const Provider(Logger, useValue: silentLogger)]
-//#enddocregion providers-7-unchecked
- */
)
class ProviderComponent7 {
- String log;
+ String message;
- ProviderComponent7(SilentLogger logger) {
- logger.log('Hello from logger provided with useValue');
- log = logger.logs[0];
+ ProviderComponent7(Logger logger) {
+ logger.log('Hello from configurable logger.');
+ message = logger.logs.last;
}
}
-/////////////////
@Component(selector: 'provider-8', template: '{{log}}', providers: const [
const Provider(HeroService, useFactory: heroServiceFactory),
Logger,
@@ -219,129 +223,103 @@ class ProviderComponent8 {
var log = 'Hero service injected successfully';
}
-/////////////////
-@Component(selector: 'provider-9a', template: '{{log}}', providers:
-/*
- // #docregion providers-9a-interface
- // WOKRKS! Can use abstract class as provider token
- [provide(Config, {useValue: CONFIG})]
- // #enddocregion providers-9a-interface
- */
-
-// #docregion providers-9a
-// Use string as provider token
-const [const Provider('app.config', useValue: CONFIG_HASH)]
-//#enddocregion providers-9a
+@Component(
+ selector: 'provider-9',
+ template: '{{log}}',
+ providers:
+// #docregion providers-9
+const [const Provider(AppConfig, useValue: config1)]
+// #enddocregion providers-9
)
-class ProviderComponent9a implements OnInit {
- Config _config;
-
+class ProviderComponent9 implements OnInit {
+ AppConfig _config;
String log;
- /*
- // #docregion provider-9a-ctor-interface
- // WORKS! Can inject using the abstract class as the parameter type
- Config _config;
-
- ProviderComponent9a(this._config);
- // #enddocregion provider-9a-ctor-interface
- */
-
- // #docregion provider-9a-ctor
+ ProviderComponent9(AppConfig this._config);
- // @Inject(token) to inject the dependency
- ProviderComponent9a(@Inject('app.config') Map config) {
- _config = new ConfigImpl(apiEndpoint: config['apiEndpoint'], title: config['title']);
- }
-
- // #enddocregion provider-9a-ctor
- ngOnInit() {
- log = '\'app.config\' Application title is ' + _config.title;
+ @override
+ void ngOnInit() {
+ log = 'appConfigToken Application title is ${_config.title}';
}
}
-@Component(selector: 'provider-9b', template: '{{log}}', providers:
-// #docregion providers-9b
-const [const Provider(APP_CONFIG, useValue: CONFIG_HASH)]) // #enddocregion providers-9b
-class ProviderComponent9b
- implements OnInit {
- Config _config;
-
- String log;
-
- // #docregion provider-9b-ctor
- ProviderComponent9b(@Inject(APP_CONFIG) Map config) {
- _config = new ConfigImpl(apiEndpoint: config['apiEndpoint'], title: config['title']);
- }
-
- // #enddocregion provider-9b-ctor
- ngOnInit() {
- log = 'APP_CONFIG Application title is ' + _config.title;
- }
-}
-//////////////////////////////////////////
-
// Normal required logger
@Component(selector: 'provider-10a', template: '{{log}}',
//#docregion providers-logger
providers: const [Logger]
//#enddocregion providers-logger
-)
+ )
class ProviderComponent10a {
String log;
ProviderComponent10a(Logger logger) {
logger.log('Hello from the required logger.');
- log = logger.logs[0];
+ log = logger.logs.last;
}
}
-// Optional logger
+// Optional logger, can be null
@Component(selector: 'provider-10b', template: '{{log}}')
-class ProviderComponent10b implements OnInit {
- Logger _logger;
-
+class ProviderComponent10b {
// #docregion provider-10-ctor
+ final Logger _logger;
String log;
- ProviderComponent10b(@Optional() this._logger);
-
+ ProviderComponent10b(@Optional() Logger this._logger) {
+ // . . .
// #enddocregion provider-10-ctor
- ngOnInit() {
- // #docregion provider-10-logger
+ _logger == null ? log = 'No logger exists' : log = _logger.logs.last;
+ // #docregion provider-10-ctor
+ }
+ // #enddocregion provider-10-ctor
+}
- // No logger? Make one!
- if (_logger == null) {
- _logger = new Logger();
- // #enddocregion provider-10-logger
- _logger.log('Optional logger was not available.');
- } else {
- _logger.log('Hello from the injected logger.');
- log = _logger.logs[0];
- }
- log = _logger.logs[0];
+// Optional logger, non null
+@Component(selector: 'provider-10c', template: '{{log}}')
+class ProviderComponent10c {
+ // #docregion provider-10-logger
+ final Logger _logger;
+ String log;
+
+ ProviderComponent10c(@Optional() Logger logger) :
+ _logger = logger ?? new DoNothingLogger() {
+ // . . .
+ // #enddocregion provider-10-logger
+ logger == null
+ ? _logger.log('Optional logger was not available.')
+ : _logger.log('Hello from the injected logger.');
+ log = _logger.logs.last;
+ // #docregion provider-10-logger
}
+// #enddocregion provider-10-logger
+}
+
+// #docregion provider-10-logger
+// . . .
+@Injectable()
+class DoNothingLogger extends Logger {
+ @override List logs = [];
+ @override void log(String msg) => logs.add(msg);
}
+// #enddocregion provider-10-logger
-/////////////////
@Component(
selector: 'my-providers',
template: '''
- Provider variations
-
-
-
-
-
-
-
-
-
-
-
-
-
- ''',
+ Provider variations
+
+
+
+
+
+
+
+
+
+
+
+
+ ''',
directives: const [
ProviderComponent1,
ProviderComponent2,
@@ -352,9 +330,9 @@ class ProviderComponent10b implements OnInit {
ProviderComponent6b,
ProviderComponent7,
ProviderComponent8,
- ProviderComponent9a,
- ProviderComponent9b,
+ ProviderComponent9,
ProviderComponent10a,
- ProviderComponent10b
+ ProviderComponent10b,
+ ProviderComponent10c
])
class ProvidersComponent {}
diff --git a/public/docs/_examples/dependency-injection/dart/lib/user_service.dart b/public/docs/_examples/dependency-injection/dart/lib/user_service.dart
index 682a42b967..5b6cabf960 100644
--- a/public/docs/_examples/dependency-injection/dart/lib/user_service.dart
+++ b/public/docs/_examples/dependency-injection/dart/lib/user_service.dart
@@ -1,5 +1,4 @@
// #docregion
-
import 'package:angular2/core.dart';
@Injectable()
diff --git a/public/docs/_examples/dependency-injection/dart/pubspec.yaml b/public/docs/_examples/dependency-injection/dart/pubspec.yaml
index 6a42a54bd3..d4e3d9b0e8 100644
--- a/public/docs/_examples/dependency-injection/dart/pubspec.yaml
+++ b/public/docs/_examples/dependency-injection/dart/pubspec.yaml
@@ -5,9 +5,9 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
- angular2: 2.0.0-beta.11
+ angular2: 2.0.0-beta.13.1
browser: ^0.10.0
- dart_to_js_script_rewriter: ^0.1.0
+ dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives: 'package:angular2/common.dart#COMMON_DIRECTIVES'
diff --git a/public/docs/_examples/dependency-injection/dart/test/hero_list_component_test.dart b/public/docs/_examples/dependency-injection/dart/test/hero_list_component_test.dart
index 0dd76b4f15..1c45babc68 100644
--- a/public/docs/_examples/dependency-injection/dart/test/hero_list_component_test.dart
+++ b/public/docs/_examples/dependency-injection/dart/test/hero_list_component_test.dart
@@ -1,6 +1,6 @@
// A simple test
// More details will be in the testing chapter.
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'package:dependency_injection/heroes/hero.dart';
import 'package:dependency_injection/heroes/hero_list_component.dart';
import 'package:dependency_injection/heroes/hero_service.dart';
@@ -31,4 +31,4 @@ void main() {
expect(hlc.heroes.length, expectedHeroes.length);
});
}
-//#enddocregion spec
\ No newline at end of file
+//#enddocregion spec
diff --git a/public/docs/_examples/dependency-injection/dart/web/index.html b/public/docs/_examples/dependency-injection/dart/web/index.html
index dd40fd6c61..cd3dfdb6cf 100644
--- a/public/docs/_examples/dependency-injection/dart/web/index.html
+++ b/public/docs/_examples/dependency-injection/dart/web/index.html
@@ -1,15 +1,15 @@
-
+
-
- Dependency Injection
-
-
-
-
-
-Loading my-app ...
-Loading my-providers ...
-
+
+ Dependency Injection
+
+
+
+
+
+ Loading...
+ Loading my-providers ...
+
diff --git a/public/docs/_examples/dependency-injection/dart/web/main.dart b/public/docs/_examples/dependency-injection/dart/web/main.dart
index 8e908cc892..abc5a9c88e 100644
--- a/public/docs/_examples/dependency-injection/dart/web/main.dart
+++ b/public/docs/_examples/dependency-injection/dart/web/main.dart
@@ -1,6 +1,6 @@
//#docregion
-
import 'package:angular2/platform/browser.dart';
+
import 'package:dependency_injection/app_component.dart';
import 'package:dependency_injection/providers_component.dart';
@@ -9,4 +9,4 @@ main() {
bootstrap(AppComponent);
//#enddocregion bootstrap
bootstrap(ProvidersComponent);
-}
\ No newline at end of file
+}
diff --git a/public/docs/_examples/dependency-injection/dart/web/main_1.dart b/public/docs/_examples/dependency-injection/dart/web/main_1.dart
index ff9166ccf1..b621869c60 100644
--- a/public/docs/_examples/dependency-injection/dart/web/main_1.dart
+++ b/public/docs/_examples/dependency-injection/dart/web/main_1.dart
@@ -1,10 +1,10 @@
import 'package:angular2/platform/browser.dart';
import 'package:dependency_injection/app_component.dart';
import 'package:dependency_injection/heroes/hero_service.dart';
-//#docregion bootstrap
main() {
-// Injecting services in bootstrap works but is discouraged
- bootstrap(AppComponent, [HeroService]);
-//#enddocregion bootstrap
-}
\ No newline at end of file
+ //#docregion bootstrap
+ bootstrap(AppComponent,
+ [HeroService]); // DISCOURAGED (but works)
+ //#enddocregion bootstrap
+}
diff --git a/public/docs/_examples/dependency-injection/ts/app/injector.component.ts b/public/docs/_examples/dependency-injection/ts/app/injector.component.ts
index 300eaee9d3..9914e7d029 100644
--- a/public/docs/_examples/dependency-injection/ts/app/injector.component.ts
+++ b/public/docs/_examples/dependency-injection/ts/app/injector.component.ts
@@ -12,7 +12,7 @@ import {Logger} from './logger.service';
selector: 'my-injectors',
template: `
Other Injections
- {{car.drive()}}
+ {{car.drive()}}
{{hero.name}}
{{rodent}}
`,
diff --git a/public/docs/_examples/displaying-data/dart/lib/app_component.dart b/public/docs/_examples/displaying-data/dart/lib/app_component.dart
index 5374ba81a8..a5c04369e7 100644
--- a/public/docs/_examples/displaying-data/dart/lib/app_component.dart
+++ b/public/docs/_examples/displaying-data/dart/lib/app_component.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/displaying-data/dart/lib/app_component_1.dart b/public/docs/_examples/displaying-data/dart/lib/app_component_1.dart
index 1991a6645c..20f946fcc5 100644
--- a/public/docs/_examples/displaying-data/dart/lib/app_component_1.dart
+++ b/public/docs/_examples/displaying-data/dart/lib/app_component_1.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
@Component(
selector: 'my-app',
diff --git a/public/docs/_examples/displaying-data/dart/lib/app_component_2.dart b/public/docs/_examples/displaying-data/dart/lib/app_component_2.dart
index ff97982532..52162e38e3 100644
--- a/public/docs/_examples/displaying-data/dart/lib/app_component_2.dart
+++ b/public/docs/_examples/displaying-data/dart/lib/app_component_2.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
// #docregion mock-heroes
const List _heroes = const [
diff --git a/public/docs/_examples/displaying-data/dart/lib/app_component_3.dart b/public/docs/_examples/displaying-data/dart/lib/app_component_3.dart
index 9a39808d18..69f424d797 100644
--- a/public/docs/_examples/displaying-data/dart/lib/app_component_3.dart
+++ b/public/docs/_examples/displaying-data/dart/lib/app_component_3.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
// #docregion heroes
import 'hero.dart';
diff --git a/public/docs/_examples/displaying-data/dart/pubspec.yaml b/public/docs/_examples/displaying-data/dart/pubspec.yaml
index b221a9737d..2b84f672ac 100644
--- a/public/docs/_examples/displaying-data/dart/pubspec.yaml
+++ b/public/docs/_examples/displaying-data/dart/pubspec.yaml
@@ -5,9 +5,9 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
- angular2: 2.0.0-beta.11
+ angular2: 2.0.0-beta.13.1
browser: ^0.10.0
- dart_to_js_script_rewriter: ^0.1.0
+ dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives: 'package:angular2/common.dart#CORE_DIRECTIVES'
diff --git a/public/docs/_examples/displaying-data/dart/web/main.dart b/public/docs/_examples/displaying-data/dart/web/main.dart
index 69650f0740..6a3620979c 100644
--- a/public/docs/_examples/displaying-data/dart/web/main.dart
+++ b/public/docs/_examples/displaying-data/dart/web/main.dart
@@ -1,7 +1,8 @@
// #docplaster
// #docregion final
-import 'package:angular2/bootstrap.dart';
+import 'package:angular2/platform/browser.dart';
// #enddocregion final
+
//import 'package:displaying_data/app_component_1.dart' as v1;
//import 'package:displaying_data/app_component_2.dart' as v2;
//import 'package:displaying_data/app_component_3.dart' as v3;
diff --git a/public/docs/_examples/forms/dart/lib/hero_form_component.dart b/public/docs/_examples/forms/dart/lib/hero_form_component.dart
index 92f82cf0b1..e5d49a08c9 100644
--- a/public/docs/_examples/forms/dart/lib/hero_form_component.dart
+++ b/public/docs/_examples/forms/dart/lib/hero_form_component.dart
@@ -1,7 +1,7 @@
// #docplaster
// #docregion
// #docregion no-todo
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/forms/dart/lib/hero_form_component_initial.dart b/public/docs/_examples/forms/dart/lib/hero_form_component_initial.dart
index 3ba6afb443..53a2c20482 100644
--- a/public/docs/_examples/forms/dart/lib/hero_form_component_initial.dart
+++ b/public/docs/_examples/forms/dart/lib/hero_form_component_initial.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
@Component(selector: 'hero-form', template: 'Hero form will go here')
class HeroFormComponent {}
diff --git a/public/docs/_examples/forms/dart/pubspec.yaml b/public/docs/_examples/forms/dart/pubspec.yaml
index df6c6dc0c0..fc5c811770 100644
--- a/public/docs/_examples/forms/dart/pubspec.yaml
+++ b/public/docs/_examples/forms/dart/pubspec.yaml
@@ -5,9 +5,9 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
- angular2: 2.0.0-beta.11
+ angular2: 2.0.0-beta.13.1
browser: ^0.10.0
- dart_to_js_script_rewriter: ^0.1.0
+ dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives:
diff --git a/public/docs/_examples/forms/dart/web/main.dart b/public/docs/_examples/forms/dart/web/main.dart
index 24a30874e3..7d21d9e9ba 100644
--- a/public/docs/_examples/forms/dart/web/main.dart
+++ b/public/docs/_examples/forms/dart/web/main.dart
@@ -1,5 +1,6 @@
// #docregion
-import 'package:angular2/bootstrap.dart';
+import 'package:angular2/platform/browser.dart';
+
import 'package:hero_form/hero_form_component.dart';
main() {
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero.dart
index 3a9ec96783..d62e5548da 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
class Hero {
String name;
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_card_component.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_card_component.dart
index bb4b2cfd1e..6fa8aeb6cd 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_card_component.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_card_component.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_editor_component.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_editor_component.dart
index 3619d3ab0d..7ad3226755 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_editor_component.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/hero_editor_component.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
import 'restore_service.dart';
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_list_component.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_list_component.dart
index 90fbc8e2c4..c484b2091d 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_list_component.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_list_component.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'edit_item.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_service.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_service.dart
index adc97586ac..c02eeb7539 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_service.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/heroes_service.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
import 'hero.dart';
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/restore_service.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/restore_service.dart
index a6d8c59d35..8ddb820f05 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/lib/restore_service.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/lib/restore_service.dart
@@ -1,5 +1,5 @@
// #docregion
-import 'package:angular2/angular2.dart';
+import 'package:angular2/core.dart';
@Injectable()
class RestoreService {
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml b/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml
index 550b9c5b31..4f51a27692 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml
@@ -5,9 +5,9 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
- angular2: 2.0.0-beta.11
+ angular2: 2.0.0-beta.13.1
browser: ^0.10.0
- dart_to_js_script_rewriter: ^0.1.0
+ dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives: 'package:angular2/common.dart#COMMON_DIRECTIVES'
diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/web/main.dart b/public/docs/_examples/hierarchical-dependency-injection/dart/web/main.dart
index a265c21e69..4b181c2ab5 100644
--- a/public/docs/_examples/hierarchical-dependency-injection/dart/web/main.dart
+++ b/public/docs/_examples/hierarchical-dependency-injection/dart/web/main.dart
@@ -1,5 +1,6 @@
// #docregion
-import 'package:angular2/bootstrap.dart';
+import 'package:angular2/platform/browser.dart';
+
import 'package:hierarchical_di/heroes_list_component.dart';
import 'package:hierarchical_di/heroes_service.dart';
diff --git a/public/docs/_examples/homepage-hello-world/ts/index.1.html b/public/docs/_examples/homepage-hello-world/ts/index.1.html
index b76916e721..3b747789d7 100644
--- a/public/docs/_examples/homepage-hello-world/ts/index.1.html
+++ b/public/docs/_examples/homepage-hello-world/ts/index.1.html
@@ -9,14 +9,14 @@
-
-
+
+
-
-
-
+
+
+
-
+
Loading...
-