Created
September 22, 2017 07:12
-
-
Save molcik/4ba97103d56b2467dc45d4656c846c72 to your computer and use it in GitHub Desktop.
app.ts
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
import {Component, NgModule, VERSION} from '@angular/core' | |
import {Http} from '@angular/http'// DON'T FORGOT TO IMPORT HTTP | |
import {BrowserModule} from '@angular/platform-browser' | |
import {HttpModule} from '@angular/http'; // DON'T FORGOT TO IMPORT HTTPMODULE | |
@Component({ | |
selector: 'my-app', | |
template: | |
`<div> | |
<h2>Response from server: {{greeting}}</h2> | |
</div>` | |
}) | |
export class App { | |
greeting:string; | |
constructor(protected http: Http) { | |
this.requestGreeting() | |
} | |
requestGreeting() { | |
this.http.get("https://private-8ace8-helloworld409.apiary-mock.com/greeting").subscribe(res => { | |
this.greeting = res.json().data; | |
}) | |
} | |
} | |
@NgModule({ | |
imports: [ BrowserModule, HttpModule ], // DON'T FORGOT TO IMPORT HTTPMODULE | |
declarations: [ App ], | |
bootstrap: [ App ] | |
}) | |
export class AppModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment