Calling Observable method using subscribe and return data in a subscribe 'd call.
Calling method:
onClick(fileName){
this._service.getFiles(fileName).subscribe(filestring => {
console.log('filestring',filestring.fileContent);
}, (err)=> {
console.log('Error to get file',err);
});
}
Called method:
Calling method:
onClick(fileName){
this._service.getFiles(fileName).subscribe(filestring => {
console.log('filestring',filestring.fileContent);
}, (err)=> {
console.log('Error to get file',err);
});
}
Called method:
getFiles(fileName): Observable<any> {
return this._http
.get(this.baseUrl + '/' + fileName, this.options())
.map((res: Response) => res.json()
)
}
Comments
Post a Comment