making components update
This commit is contained in:
parent
345a013156
commit
69b6bf969b
|
@ -4,7 +4,7 @@
|
||||||
If you want to skip to the working examples you can check out these links on Plunker. <a href='http://plnkr.co/edit/lt7vPiJYwkHDKaTHGCUC?p=preview')>TypeScript Example</a> or <a href='http://plnkr.co/edit/CqquuEyUw2LgwY0IrXUZ?p=preview'> ES5 Example</a>.
|
If you want to skip to the working examples you can check out these links on Plunker. <a href='http://plnkr.co/edit/lt7vPiJYwkHDKaTHGCUC?p=preview')>TypeScript Example</a> or <a href='http://plnkr.co/edit/CqquuEyUw2LgwY0IrXUZ?p=preview'> ES5 Example</a>.
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
|
|
||||||
h2#section-its-all-a-tree It's all a tree
|
h2#section-its-all-a-tree It's all a tree
|
||||||
|
|
||||||
p.
|
p.
|
||||||
|
@ -15,78 +15,80 @@
|
||||||
Given a bootstrapping template with a <code><parent></code> tag in the body, you can create a parent
|
Given a bootstrapping template with a <code><parent></code> tag in the body, you can create a parent
|
||||||
component that uses a <code><child></code> component like so:
|
component that uses a <code><child></code> component like so:
|
||||||
|
|
||||||
pre.prettyprint.linenums.lang-javascript
|
.code-box
|
||||||
code.
|
pre.prettyprint.linenums.lang-javascript(data-name="es5")
|
||||||
//ES5
|
code.
|
||||||
function ParentComponent() {
|
//ES5
|
||||||
this.message = "I'm the parent";
|
function ParentComponent() {
|
||||||
}
|
|
||||||
ParentComponent.annotations = [
|
|
||||||
new angular.Component({
|
|
||||||
selector: "parent"
|
|
||||||
}),
|
|
||||||
new angular.View({
|
|
||||||
template:
|
|
||||||
'<h1>{{ message }}</h1>' +
|
|
||||||
'<child></child>',
|
|
||||||
directives: [ChildComponent]
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
pre.prettyprint.linenums.lang-typescript
|
|
||||||
code.
|
|
||||||
//TypeScript
|
|
||||||
@Component({
|
|
||||||
selector: 'parent'
|
|
||||||
})
|
|
||||||
@View({
|
|
||||||
template: `
|
|
||||||
<h1>{{ message }}</h1>
|
|
||||||
<child></child>
|
|
||||||
`,
|
|
||||||
directives: [ChildComponent]
|
|
||||||
})
|
|
||||||
class ParentComponent {
|
|
||||||
message: string;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.message = "I'm the parent";
|
this.message = "I'm the parent";
|
||||||
}
|
}
|
||||||
}
|
ParentComponent.annotations = [
|
||||||
|
new angular.Component({
|
||||||
|
selector: "parent"
|
||||||
|
}),
|
||||||
|
new angular.View({
|
||||||
|
template:
|
||||||
|
'<h1>{{ message }}</h1>' +
|
||||||
|
'<child></child>',
|
||||||
|
directives: [ChildComponent]
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
pre.prettyprint.linenums.lang-typescript(data-name="typescript")
|
||||||
|
code.
|
||||||
|
//TypeScript
|
||||||
|
@Component({
|
||||||
|
selector: 'parent'
|
||||||
|
})
|
||||||
|
@View({
|
||||||
|
template: `
|
||||||
|
<h1>{{ message }}</h1>
|
||||||
|
<child></child>
|
||||||
|
`,
|
||||||
|
directives: [ChildComponent]
|
||||||
|
})
|
||||||
|
class ParentComponent {
|
||||||
|
message: string;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.message = "I'm the parent";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p You then just need to write the <code>ChildComponent</code> class to make it work:
|
p You then just need to write the <code>ChildComponent</code> class to make it work:
|
||||||
|
|
||||||
pre.prettyprint.linenums.lang-javascript
|
.code-box
|
||||||
code.
|
pre.prettyprint.linenums.lang-javascript(data-name="es5")
|
||||||
//ES5
|
code.
|
||||||
function ChildComponent() {
|
//ES5
|
||||||
this.message = "I'm the child";
|
function ChildComponent() {
|
||||||
}
|
|
||||||
ChildComponent.annotations = [
|
|
||||||
new angular.Component({
|
|
||||||
selector: "child"
|
|
||||||
}),
|
|
||||||
new angular.View({
|
|
||||||
template: '<p> {{ message }} </p>'
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
pre.prettyprint.linenums.lang-typescript
|
|
||||||
code.
|
|
||||||
//TypeScript
|
|
||||||
@Component({
|
|
||||||
selector: 'child'
|
|
||||||
})
|
|
||||||
@View({
|
|
||||||
template: `
|
|
||||||
<p> {{ message }} </p>
|
|
||||||
`
|
|
||||||
})
|
|
||||||
class ChildComponent {
|
|
||||||
constructor() {
|
|
||||||
this.message = "I'm the child";
|
this.message = "I'm the child";
|
||||||
}
|
}
|
||||||
}
|
ChildComponent.annotations = [
|
||||||
|
new angular.Component({
|
||||||
|
selector: "child"
|
||||||
|
}),
|
||||||
|
new angular.View({
|
||||||
|
template: '<p> {{ message }} </p>'
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
pre.prettyprint.linenums.lang-typescript(data-name="typescript")
|
||||||
|
code.
|
||||||
|
//TypeScript
|
||||||
|
@Component({
|
||||||
|
selector: 'child'
|
||||||
|
})
|
||||||
|
@View({
|
||||||
|
template: `
|
||||||
|
<p> {{ message }} </p>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
class ChildComponent {
|
||||||
|
constructor() {
|
||||||
|
this.message = "I'm the child";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p.
|
p.
|
||||||
Notice that in addition to using the <code><child></code> element in the parent template, you also need to
|
Notice that in addition to using the <code><child></code> element in the parent template, you also need to
|
||||||
|
|
Loading…
Reference in New Issue