Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { Component, OnInit } from '@angular/core';
import { MyService } from '/myService.service';
@Component({
selector: 'app-MyComponent-interface',
templateUrl: './MyComponent.component.html',
styleUrls: ['./MyComponent.component.css']
})
export class MyComponent implements OnInit {
constructor(private myService:MyService) { }
ngOnInit() {
this.getRecentData().subscribe(data=>{
//use response
}
}
getRecentData(){
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
return this.http.get( '/recentData', options).map(res=>res.json()); //No Base URL required
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.