Skip to content

Instantly share code, notes, and snippets.

@wickedrahul
Last active Feb 21, 2018
Embed
What would you like to do?
My Service for proxy routing
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(this.myService.getBaseUrl()+ 'recentData', options).map(res=>res.json());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment