Last active
August 29, 2015 14:20
-
-
Save damienwebdev/7f5c615a04dec3f2569b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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