Skip to content

Instantly share code, notes, and snippets.

@bkad
Last active August 19, 2016 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkad/8072ebbf88cb6777572c19a6aa311860 to your computer and use it in GitHub Desktop.
Save bkad/8072ebbf88cb6777572c19a6aa311860 to your computer and use it in GitHub Desktop.
{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)
{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