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

Commit 543f6d9

Browse files
committed
add input/output section
1 parent 09b0980 commit 543f6d9

File tree

1 file changed

+29
-41
lines changed

1 file changed

+29
-41
lines changed

public/docs/js/latest/cookbook/ts-to-js.jade

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ a(id="class-metadata")
165165
For example, a component must have a
166166
[`@Component`](../api/core/index/Component-decorator.html) decorator.
167167

168-
On ES6 or ES5 Javascript we can instead attach an `annotations` array to a class/constructor
168+
On ES5/6 Javascript we can instead attach an `annotations` array to a class/constructor
169169
to provide metadata.
170170
Each item in the array corresponds to a decorator.
171171

@@ -177,7 +177,6 @@ a(id="class-metadata")
177177
method call.
178178
The argument to `Class` is an object that defines the constructor and the instance methods
179179
of the component.
180-
181180
Similar APIs are also available for other decorators. You can define a directive with
182181
`ng.core.Directive` or a pipe with `ng.core.Pipe`.
183182

@@ -210,7 +209,7 @@ a(id="class-metadata")
210209
`ngOnInit` is defined in the `OnInit` interface.
211210

212211
TypeScript interfaces are purely for developer convenience and are not used by Angular at runtime.
213-
This means that in ES6 or ES5 JavaScript code we don't need to substitute anything for interfaces.
212+
This means that in ES5/6 JavaScript code we don't need to substitute anything for interfaces.
214213
We can just implement the methods.
215214

216215
+makeTabs(`
@@ -231,46 +230,35 @@ a(id="property-metadata")
231230
:marked
232231
## Input and Output Metadata
233232

234-
- var top="vertical-align:top"
235-
table(width="100%")
236-
col(width="50%")
237-
col(width="50%")
238-
tr
239-
th TypeScript
240-
th ES5 JavaScript
241-
tr(style=top)
242-
td
243-
:marked
244-
### Input and Output Decorators
245-
246-
In TypeScript, property decorators are often used to provide additional metadata
247-
for components and directives.
233+
### Input and Output Decorators
248234

249-
For [inputs and outputs](../guide/template-syntax.html#inputs-outputs),
250-
we use `@Input` and `@Output` property decorators.
251-
They may optionally specify input and output binding names if we want them to be
252-
different from the class property names.
253-
254-
+makeExample('cb-ts-to-js/ts/app/hero-io.component.ts')(format="." )
255-
256-
.alert.is-helpful
257-
:marked
258-
In TypeScript we can also use the `inputs` and `outputs` array metadata
259-
instead of the `@Input` and `@Output` property decorators.
260-
td
261-
:marked
262-
### Inputs and Outputs in Component Metadata
263-
264-
There is no equivalent of a property decorator in ES5 JavaScript. Instead,
265-
we add comparable information to the `Component` (or `Directive`) metadata.
266-
267-
In this example, we add `inputs` and `outputs` array attributes
268-
containing the input and output property names.
269-
If we need a binding name that is different from the
270-
property itself, we use the `propertyName: bindingName` syntax.
271-
272-
+makeExample('cb-ts-to-js/js/app/hero-io.component.js')(format="." )
235+
In TypeScript and ES6 with decorators, property decorators are often used to provide additional
236+
metadata for components and directives.
237+
For [inputs and outputs](../guide/template-syntax.html#inputs-outputs), we use `@Input` and
238+
`@Output` property decorators.
239+
They may optionally specify input and output binding names if we want them to be different
240+
from the class property names.
273241

242+
There is no equivalent of a property decorator in ES5/6 JavaScript.
243+
Instead, we add comparable information to the `Component` (or `Directive`) metadata.
244+
245+
In this example, we add `inputs` and `outputs` array attributes containing the input and
246+
output property names.
247+
If we need a binding name that is different from the property itself, we use the
248+
`propertyName: bindingName` syntax.
249+
250+
+makeTabs(`
251+
cb-ts-to-js/ts/app/hero-io.component.ts,
252+
cb-ts-to-js/js-es6-decorators/app/hero-io.component.es6,
253+
cb-ts-to-js/js-es6/app/hero-io.component.es6,
254+
cb-ts-to-js/js/app/hero-io.component.js
255+
`,`
256+
`,`
257+
Typescript,
258+
ES6 Javascript with decorators,
259+
ES6 Javascript,
260+
ES5 Javascript
261+
`)
274262

275263
.l-main-section
276264
:marked

0 commit comments

Comments
 (0)