Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 55d42c4

Browse files
committed
docs(cb-ts-to-js): Ward's tweaks to cookbook about applying TypeScript examples to ES5
1 parent 29aad37 commit 55d42c4

20 files changed

+251
-168
lines changed

public/docs/_examples/cb-ts-to-js/js/app/hero-di-inject.component.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function(app) {
22

3-
// #docregion
3+
// #docregion parameters
44
function HeroComponent(name) {
55
this.name = name;
66
}
@@ -13,7 +13,27 @@
1313
template: '<h1>Hero: {{name}}</h1>'
1414
})
1515
];
16-
// #enddocregion
16+
// #enddocregion parameters
17+
1718
app.HeroDIInjectComponent = HeroComponent;
19+
20+
})(window.app = window.app || {});
21+
22+
(function(app) {
23+
// #docregion ctor
24+
var HeroComponent = ng.core.Component({
25+
selector: 'hero-di-inline2',
26+
template: '<h1>Hero: {{name}}</h1>'
27+
})
28+
.Class({
29+
constructor:
30+
[new ng.core.Inject('heroName'),
31+
function(name) {
32+
this.name = name;
33+
}]
34+
});
35+
// #enddocregion ctor
36+
37+
app.HeroDIInjectComponent2 = HeroComponent;
1838

1939
})(window.app = window.app || {});

public/docs/_examples/cb-ts-to-js/js/app/hero-di-inline.component.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
})
77
.Class({
88
constructor:
9-
[app.DataService, function(service) {
10-
this.name = service.getHeroName();
11-
}]
9+
[app.DataService,
10+
function(service) {
11+
this.name = service.getHeroName();
12+
}]
1213
});
1314
// #enddocregion
1415
app.HeroDIInlineComponent = HeroComponent;

public/docs/_examples/cb-ts-to-js/js/app/hero-di.component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
(function(app) {
22

33
// #docregion
4+
app.HeroDIComponent = HeroComponent;
5+
46
function HeroComponent(dataService) {
57
this.name = dataService.getHeroName();
68
}
@@ -14,6 +16,5 @@
1416
})
1517
];
1618
// #enddocregion
17-
app.HeroDIComponent = HeroComponent;
1819

1920
})(window.app = window.app || {});

public/docs/_examples/cb-ts-to-js/js/app/hero-dsl.component.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// #docplaster
2+
// #docregion appexport
13
(function(app) {
24

35
// #docregion component

public/docs/_examples/cb-ts-to-js/js/app/hero-lifecycle.component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
// #docplaster
12
(function(app) {
23
// #docregion
3-
function HeroComponent() {
4-
}
4+
function HeroComponent() {}
55
// #enddocregion
66
HeroComponent.annotations = [
77
new ng.core.Component({

public/docs/_examples/cb-ts-to-js/js/app/hero.component.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docplaster
12
// #docregion appexport
23
(function(app) {
34
// #enddocregion appexport
@@ -6,7 +7,9 @@
67
// #docregion appexport
78
// #docregion constructorproto
89
function HeroComponent() {
10+
this.title = "Hero Detail";
911
}
12+
1013
// #enddocregion constructorproto
1114
// #enddocregion appexport
1215
HeroComponent.annotations = [
@@ -18,9 +21,7 @@
1821
];
1922
// #docregion constructorproto
2023
HeroComponent.prototype.getName =
21-
function() {
22-
return 'Windstorm';
23-
};
24+
function() {return 'Windstorm';};
2425
// #enddocregion constructorproto
2526
// #enddocregion metadata
2627

public/docs/_examples/cb-ts-to-js/js/app/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docplaster
12
// #docregion appimport
23
(function(app) {
34
// #enddocregion appimport
@@ -26,6 +27,9 @@
2627
bootstrap(app.HeroDIInjectComponent, [
2728
ng.core.provide('heroName', {useValue: 'Windstorm'})
2829
]);
30+
bootstrap(app.HeroDIInjectComponent2, [
31+
ng.core.provide('heroName', {useValue: 'Bombasto'})
32+
]);
2933
bootstrap(app.HeroDIInjectAdditionalComponent);
3034
bootstrap(app.HeroIOComponent);
3135
bootstrap(app.HeroesHostBindingsComponent);

public/docs/_examples/cb-ts-to-js/js/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<hero-lifecycle>Loading app...</hero-lifecycle>
3434
<hero-di>Loading app...</hero-di>
3535
<hero-di-inline>Loading app...</hero-di-inline>
36+
<hero-di-inline2>Loading app...</hero-di-inline2>
3637
<hero-di-inject>Loading app...</hero-di-inject>
3738
<hero-di-inject-additional>Loading app...</hero-di-inject-additional>
3839
<hero-io>Loading app...</hero-io>

public/docs/_examples/cb-ts-to-js/ts/app/hero-io.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export class ConfirmComponent {
2626
onNotOkClick() {
2727
this.notOk.next(true);
2828
}
29-
3029
}
3130
// #enddocregion
3231

public/docs/_examples/cb-ts-to-js/ts/app/hero-lifecycle.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docplaster
12
// #docregion
23
import {Component, OnInit}
34
from 'angular2/core';

0 commit comments

Comments
 (0)