Last active
August 19, 2016 00:36
-
-
Save bkad/8072ebbf88cb6777572c19a6aa311860 to your computer and use it in GitHub Desktop.
This file contains 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
{Component} = require("angular2/core") | |
annotate = require("./annotate") | |
MessageService = require("./message.service") | |
class AppComponent | |
decorators: [ | |
Component | |
selector: "app" | |
template: """ | |
<div *ngFor="let message of messages"> | |
{{message}} | |
</div> | |
""" | |
providers: [MessageService] | |
] | |
parameters: [MessageService] | |
constructor: (messageService) -> | |
@messageService = messageService | |
messages: [] | |
ngOnInit: -> | |
@getMessages() | |
getMessages: -> | |
@messageService.getMessages() | |
.then(@setMessages) | |
setMessages: (messages) => # I missed you, fat arrow | |
@messages = messages | |
module.exports = annotate(AppComponent) |
This file contains 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
{Injectable} = require("angular2/core") | |
annotate = require("./annotate") | |
class MessageService | |
decorators: [Injectable()] | |
getMessages: -> | |
Promise.resolve(["hey", "hi"]) | |
module.exports = annotate(MessageService) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment