Answer the question
In order to leave comments, you need to log in
How to get rid of the error "Cannot read property 'attribut_id' of undefined"?
I get this error when loading the page:
ERROR TypeError: Cannot read property 'attribut_id' of undefined
at eval (values.component.ts:132)
at Array.filter ()
at SafeSubscriber.eval [as _next] (values.component.ts:132)
at SafeSubscriber.__tryOrUnsub ( Subscriber.js:243)
at SafeSubscriber.next (Subscriber.js:190)
at Subscriber._next (Subscriber.js:131)
at Subscriber.next (Subscriber.js:95)
at MapSubscriber._next (map.js:85)
at MapSubscriber.Subscriber.next(Subscriber.js:95)
at RefCountSubscriber.Subscriber._next(Subscriber.js:131)
...
export class ValuesComponent implements OnInit {
values: Array<Value>;
atributes: Array<Attribute>;
filteredValues = [];
constructor(
public authTokenService: Angular2TokenService,
private servAttribute: AttributeService,
private servValue: ValueService
) {
}
@Input() attribute: Attribute;
ngOnInit() {
this.loadValues();
}
private loadValues() {
let filteredValues;
if (this.servValue) {
this.servValue.getValues().subscribe(value => {
this.values = value;
this.filteredValues = this.values.filter((value) => value.l_attributs_id == this.attribute.attribut_id);
});
}
}
}
Answer the question
In order to leave comments, you need to log in
this.servValue.getValues().subscribe(value => {
if(!this.attribute) { return; }
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question