I have a file called globalvars.ts where I added a global method. How can I subscribe to this method in the ts page where it is being called?
globalvars.ts;
httpgetmethod(url:string)
{
var veri;
var headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json' );
headers.append('Authorization' , 'Bearer '+ "");
let options = new RequestOptions({ headers: headers });
this.http.get(url, options)
.subscribe(data => {
console.log( data['_body']);
veri=data['_body'];
veri = veri.replace(/\\/g, "");
veri = JSON.parse(veri);
return veri;
});
profile.ts;
globalvars.httpgetmethod("").subscribe;
I want to invoke the subscription here.
Thanks.