nlr_p nlr_p - 3 months ago 21
TypeScript Question

how to subscribe to back end data in angular js2

export class Search {

data: string;
prop: string = 'connenct';
details: ISearch[];
constructor(public http: Http,public _profileservice: GetSocietyList) {
this.http = http;
this._profileservice.getSocietyList()
.subscribe(
response => {
this.details = response;

})
})

}


Here i am subscribing the whole response to details but i want only some part of my details i.e where connection_status = 3 and 4.Can some one please suggest help.

Answer

Just filter what you need

response => {
  this.details = response.filter(
    r => r.connection_status === 3 || r.connnection_status === 4);