I have a nested Observable (child) which gets updated frequently. However
the parent Observable doesn't seem to detect the change/change the view.
The parent Observable is used in the template using an ngFor which is using
a custom pipe (a filter which uses the child Observables data) and the
async pipe. How can I force the view to filter my parent Observable when
one of the child Observables changes?
app.js
// This is an Observable generated by AngularFire 2 because I am using Firebase
this.items = af.list('/items').map( (items) => {
return items.map( item => {
item.meta = af.object(`/item_meta/${item.$key}`)
return item
})
})
// My custom pipe
@Pipe({
name: 'customPipe'
})
class CustomPipe implements PipeTransform {
transform(items: any[]) {
return projects.filter(hasMinimalStockPrice)
}
}
index.html
<ion-card *ngFor="#item of items | customPipe | async">
<ion-card-header>
{{item.name}}
</ion-card-header>
<ion-card-content>
{{item.description}}
<br>
{{item.meta.stockPrice | async}}
</ion-card-content>
</ion-card>
data structure:
{
"items":
{
"item1":{
"name": "Item 1",
"description": "1234"
},
"item2":{
"name": "Item 2",
"description": "abcd"
}
}
"items_meta"{
"item1":{
"stockPrice": 1234,
"moarData": "derp"
},
"item2":{
"stockPrice": 386,
"moarData": "lolz"
}
}
}
I am using Firebase with AngularFire 2. This shouldn't change anything so
as far as I know this is an Angular 2/Observable problem I'm facing.
This is what I need: The stockPrice value changes, which is in in a child
Observable of items (the parent Observable). Based on the new stockPrice
the view should update to only show items which have a minimum stockPrice.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.