Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2016 15:35
What would you like to do?
import {Component} from 'angular2/core';
import {OnInit} from 'angular2/core';
import {HelloService} from './hello.service';
// Declare the tag name in index.html to where the component attaches
selector: 'hello',
// Location of the template for this component
templateUrl: 'views/hello.view.html',
// Dependencies
providers: [HelloService]
// Component controller
export class Hello implements OnInit {
public message: string;
public name: string;
constructor(private _helloService: HelloService) {
ngOnInit() { = "";
this.message = "";
sayHello() {
// Use hello service to call the API and bind result
this._helloService.sayHello( => {
this.message = response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment