Live examples and formatting.
This commit is contained in:
parent
bee30ca1ad
commit
d3f8fb741a
|
@ -1,7 +1,4 @@
|
||||||
.l-main-section
|
.l-main-section
|
||||||
p.
|
|
||||||
<strong>Mission:</strong> By the end of this chapter, you should be able to display data from both properties and
|
|
||||||
lists from a component’s controller to the view.
|
|
||||||
p.
|
p.
|
||||||
Displaying data is job number one for any good application. In Angular, you bind data to elements in HTML
|
Displaying data is job number one for any good application. In Angular, you bind data to elements in HTML
|
||||||
templates and Angular automatically updates the UI as data changes.
|
templates and Angular automatically updates the UI as data changes.
|
||||||
|
@ -14,7 +11,9 @@
|
||||||
img(src='displaying-data-example1.png')
|
img(src='displaying-data-example1.png')
|
||||||
|
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
h3#section-examples Examples:
|
h3#section-examples Live Examples
|
||||||
|
p.
|
||||||
|
If you want to skip the working examples you can check out these links on Plunker.
|
||||||
ul
|
ul
|
||||||
li
|
li
|
||||||
a(href='http://plnkr.co/edit/pQojSb3CTfTEejX0wGjO?p=preview') TypeScript
|
a(href='http://plnkr.co/edit/pQojSb3CTfTEejX0wGjO?p=preview') TypeScript
|
||||||
|
@ -302,24 +301,24 @@
|
||||||
new angular.Component({
|
new angular.Component({
|
||||||
selector: "display"
|
selector: "display"
|
||||||
}),
|
}),
|
||||||
new angular.View({
|
new angular.View({
|
||||||
template:
|
template:
|
||||||
'<p>My name: {{ myName }}</p>' +
|
'<p>My name: {{ myName }}</p>' +
|
||||||
'<p>Friends:</p>' +
|
'<p>Friends:</p>' +
|
||||||
'<ul>' +
|
'<ul>' +
|
||||||
'<li *for="#name of names">' +
|
'<li *for="#name of names">' +
|
||||||
'{{ 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]
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
pre.prettyprint.lang-typescript
|
pre.prettyprint.lang-typescript
|
||||||
code.
|
code.
|
||||||
//TypeScript
|
//TypeScript
|
||||||
import {Component, View, bootstrap, For, If} from 'angular2/angular2';
|
import {Component, View, bootstrap, For, If} from 'angular2/angular2';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'display'
|
selector: 'display'
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
|
@ -338,8 +337,8 @@
|
||||||
class DisplayComponent {
|
class DisplayComponent {
|
||||||
myName: string;
|
myName: string;
|
||||||
todos: Array<string>;
|
todos: Array<string>;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.myName = "Alice";
|
this.myName = "Alice";
|
||||||
this.names = ["Aarav", "Martín", "Shannon", "Ariana", "Kai"];
|
this.names = ["Aarav", "Martín", "Shannon", "Ariana", "Kai"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,16 @@
|
||||||
|
|
||||||
pre.prettyprint.lang-bash
|
pre.prettyprint.lang-bash
|
||||||
code python -m SimpleHTTPServer 8000
|
code python -m SimpleHTTPServer 8000
|
||||||
|
|
||||||
|
.l-sub-section
|
||||||
|
h3#section-examples Live Examples
|
||||||
|
p.
|
||||||
|
If you want to skip the working examples you can check out these links on Plunker.
|
||||||
|
ul
|
||||||
|
li
|
||||||
|
a(href='http://plnkr.co/edit/MRz2i7sjupzxERPAa3SF?p=preview') TypeScript
|
||||||
|
li
|
||||||
|
a(href='http://plnkr.co/edit/wzzKo4etk24t0oAnL6ep?p=preview') ES5
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
h2#section-create-an-entry-point Create an entry point
|
h2#section-create-an-entry-point Create an entry point
|
||||||
|
|
Loading…
Reference in New Issue