Skip to content

Instantly share code, notes, and snippets.

@damienwebdev
Last active August 29, 2015 14:20
Show Gist options
  • Save damienwebdev/7f5c615a04dec3f2569b to your computer and use it in GitHub Desktop.
Save damienwebdev/7f5c615a04dec3f2569b to your computer and use it in GitHub Desktop.
// TypeScript
import {Component, View, bootstrap, For} from 'angular2/angular2';
@Component({
selector: 'display',
})
@View({
template:
'<p>My name: {{ myName }}</p> ' +
'<p>Friends:</p>' +
'<ul> ' +
'<li *for="#name of names">' +
'{{ name }} ' +
'</li> ' +
'</ul>'
,
directives: [For]
})
class DisplayComponent {
myName: string;
names: Array<string>;
constructor(friends:FriendsService) {
this.myName = "Alice";
setInterval(function () { this.time = (new Date()).toString(); }.bind(this), 1000);
this.names = ["Alice", "Aarav", "Martin", "Shannon", "Ariana", "Kai"];
}
}
class FriendsService{
names: Array<string>;
constructor(){
this.names = ["Alice", "Aarav", "Martin", "Shannon", "Ariana", "Kai"];
}
}
bootstrap(DisplayComponent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment