I want to call a pipe with in a service.
just like
export class MyService{
constructor(private http: Http){}
getValues(){
this.http.get(baseUrl).pipe(//pipename) //I want to menton my custom pipe
}
}
After completion of pipe I want to return that observables to component. Is it possible ?
Yes, you can call pipe
in service file like this-
import { DatePipe } from '@angular/common';
class MyService {
constructor(private datePipe: DatePipe) {}
transformDate(date) {
this.datePipe.transform(myDate, 'yyyy-MM-dd');
}
}
as you have not provided any example of your use case , I am assuming DatePipe
here in my example.
export class MyService{
constructor(private http: Http, private yourPipe: YourPipe){}
getValues(){
this.http.get(baseUrl).map(res => {
return this.yourPipe.transform(res, ----whatever---);
});
}
}