Last active
February 21, 2018 09:46
-
-
Save AbGrS/f0f5982d999b2dce45995d00a2d416b1 to your computer and use it in GitHub Desktop.
My Service for proxy routing
This file contains 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, 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