import {Component} from 'angular2/core';
import {OnInit} from "angular2/core";
import {Http} from 'angular2/http';
import 'rxjs/Rx';
@Component({
selector: 'my-app',
template: `
<h1>{{title}}</h1>
<p>Test result {{result | json}}</p>
`
})
export class App implements OnInit{
public title = 'my title';
public result : String;
constructor(private _http : Http) {
_http.post('http://jsonplaceholder.typicode.com/posts')
.map(res => res.json())
.subscribe(
data => this.result = data,
err => console.log('ERROR!!!'),
() => console.log('Got response from API', this.result)
);
}
ngOnInit () {
}
}
import {OnInit} from "angular2/core";
import {Http} from 'angular2/http';
import 'rxjs/Rx';
@Component({
selector: 'my-app',
template: `
<h1>{{title}}</h1>
<p>Test result {{result | json}}</p>
`
})
export class App implements OnInit{
public title = 'my title';
public result : String;
constructor(private _http : Http) {
_http.post('http://jsonplaceholder.typicode.com/posts')
.map(res => res.json())
.subscribe(
data => this.result = data,
err => console.log('ERROR!!!'),
() => console.log('Got response from API', this.result)
);
}
ngOnInit () {
}
}