How to check the length of an Observable array

后端 未结 8 2141
旧时难觅i
旧时难觅i 2020-12-02 08:19

In my Angular 2 component I have an Observable array

list$: Observable;

In my Template

相关标签:
8条回答
  • 2020-12-02 08:59

    A solution for .ts-Files:

         this.list.subscribe(result => {console.log(result.length)});
    
    0 讨论(0)
  • 2020-12-02 08:59

    Your approach here has another major issue: by leveraging the async pipe over and over in your template, you are actually kicking off that many subscriptions to the single Observable.

    KAMRUL HASAN SHAHED has the right approach above: Use the async pipe once and then provide an alias for the result that you can leverage in child nodes.

    0 讨论(0)
提交回复
热议问题