Skip to content

Instantly share code, notes, and snippets.

@AbGrS
Last active February 21, 2018 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbGrS/f0f5982d999b2dce45995d00a2d416b1 to your computer and use it in GitHub Desktop.
Save AbGrS/f0f5982d999b2dce45995d00a2d416b1 to your computer and use it in GitHub Desktop.
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