rxjs access to object value by key

Discussão em 'Angular' iniciado por JJJanezic, Novembro 18, 2024.

  1. JJJanezic

    JJJanezic Guest

    I have an observable which is an Array of objects with key-value-pairs.

    I can get access to the first element of this array by:

    const source = this.store.select('news').pipe();
    const element = source.subscribe(val => console.log(val.news[0]));


    It logs me the object properly in the console.

    If I try to log just the newsId by

    const source = this.store.select('news').pipe(); const element = source.subscribe(val => console.log(val.news[0].newsId));

    I get an error "Cannot read property 'newsId' of undefined".

    How could the object be defined as a whole but if I try to access the object it tells me that it's undefined?

    Continue reading...

Compartilhe esta Página