Answer the question
In order to leave comments, you need to log in
Why does the filtered data not want to be displayed?
I want to display data by filtering it by id "Attribute". But the data is not displayed and there is no error in the console. The error will only occur if you remove this if(!this.attribute) { return; }
. And it will look like this:
ERROR TypeError: Cannot read property 'attribut_id' of undefined
at eval (values.component.ts:179)
at Array.filter ()
at SafeSubscriber.eval [as _next] (values.component.ts:179)
at SafeSubscriber.__tryOrUnsub ( Subscriber.js:238)
at SafeSubscriber.next (Subscriber.js:185)
at Subscriber._next (Subscriber.js:125)
at Subscriber.next (Subscriber.js:89)
at MapSubscriber._next (map.js:83)
at MapSubscriber.Subscriber.next(Subscriber.js:89)
at RefCountSubscriber.Subscriber._next(Subscriber.js:125)
values: Array<Value>;
filteredValues = [];
@Input() attribute: Attribute;
ngOnInit() {
this.loadValues();
}
private loadValues() {
this.loading = true;
let filteredValues;
if (this.servValue) {
this.servValue.getValues().subscribe(
value => {
this.loading = false;
if(!this.attribute) { return; }
this.values = value;
this.filteredValues = this.values
.filter((value) => value.l_attributs_id == this.attribute.attribut_id)
}
);
}
}
<tbody>
<tr>
<td *ngFor="let value of filteredValues" style="text-align: center;">
<b>{{value.name}}</b>
</td>
</tr>
</tbody>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question