I have a service like:
getItems(id: string): Observable<items> {
return this.http.get(this.url + id)
.map(response => response.json());
}
In component template:
<tr *ngFor="#item of items">
<td>
<another-component [values]=item.values></another-component>
</td>
</tr>
In another-component:
ngOnChanges() {
this.values.filter((value) => value.number > 0)
.map((value) => this.positive[value.id] = value.number);
}
There are list of values and id's. ı want to seperate positives before showing them.
I got an error stating .filter could not be used for undefined. After that, I use ngIf to check if property exists it works but it only shows some of values (which are resolved).
So,
How can I check all request is done and all data is ready (resolved) in a more proper way?
or is the problem I had could be resolved asynchronously?
EDIT:
I am using subscribe inside my component.
ngOnInit() {
let id = this._routeParams.get('id');
this.getItems(id)
}
this._itemsService.getItems(id).subscribe(
data => this.items = data
)
But not all of values appear from other-component since it is not completed. How could I make other-component know that it is completed, then it could filter the complete list. Since it is filtering on success not on complete, filter is applied only one or two of value and one or two value appear only.