style(guide): incorporate FriendsService into final example, If directive
This commit is contained in:
parent
7722b596fb
commit
f096b9bc6a
|
@ -297,11 +297,9 @@
|
||||||
code-pane(language="javascript" name="TypeScript" format="linenums").
|
code-pane(language="javascript" name="TypeScript" format="linenums").
|
||||||
//TypeScript
|
//TypeScript
|
||||||
import {Component, View, bootstrap, For, If} from 'angular2/angular2';
|
import {Component, View, bootstrap, For, If} from 'angular2/angular2';
|
||||||
@Component({
|
...
|
||||||
selector: 'display'
|
|
||||||
})
|
|
||||||
@View({
|
@View({
|
||||||
template: `
|
<span class='otl'>template</span>: `
|
||||||
<p>My name: {{ myName }}</p>
|
<p>My name: {{ myName }}</p>
|
||||||
<p>Friends:</p>
|
<p>Friends:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -314,25 +312,25 @@
|
||||||
directives: [For, If]
|
directives: [For, If]
|
||||||
})
|
})
|
||||||
class DisplayComponent {
|
class DisplayComponent {
|
||||||
myName: string;
|
...
|
||||||
names: Array<string>
|
}
|
||||||
|
|
||||||
|
class FriendsService {
|
||||||
|
names: Array<string>;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.myName = "Alice";
|
<span class='otl'>this.names = ["Aarav", "Martín", "Shannon"];</span>
|
||||||
this.names = ["Aarav", "Martín", "Shannon", "Ariana", "Kai"];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code-pane(language="javascript" name="ES5" format="linenums").
|
code-pane(language="javascript" name="ES5" format="linenums").
|
||||||
//ES5
|
//ES5
|
||||||
function DisplayComponent() {
|
function DisplayComponent(friends) {
|
||||||
this.myName = "Alice";
|
this.myName = "Alice";
|
||||||
this.names = ["Aarav", "Martín", "Shannon", "Ariana", "Kai"];
|
this.names = friends.names;
|
||||||
}
|
}
|
||||||
DisplayComponent.annotations = [
|
DisplayComponent.annotations = [
|
||||||
new angular.ComponentAnnotation({
|
...
|
||||||
selector: "display"
|
|
||||||
}),
|
|
||||||
new angular.ViewAnnotation({
|
new angular.ViewAnnotation({
|
||||||
template:
|
<span class='otl'>template</span>: '
|
||||||
'<p>My name: {{ myName }}</p>' +
|
'<p>My name: {{ myName }}</p>' +
|
||||||
'<p>Friends:</p>' +
|
'<p>Friends:</p>' +
|
||||||
'<ul>' +
|
'<ul>' +
|
||||||
|
@ -340,7 +338,11 @@
|
||||||
'{{ name }}' +
|
'{{ name }}' +
|
||||||
'</li>' +
|
'</li>' +
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'<p *if="names.length > 3">You have many friends!</p>',
|
'<p *if="names.length > 3">You have many friends!</p>'',
|
||||||
directives: [angular.For, angular.If]
|
directives: [angular.For, angular.If]
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function FriendsService () {
|
||||||
|
<span class='otl'>this.names = ["Aarav", "Martín", "Shannon"];</span>
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue