Get array element in observable at particular index [html]
问题 How does one go about getting a single value from an Observable that contains an array using html. Im running Angular2 w/Typescript typescript private observable = Observable.of([1,2,3,4,5]) html <p>{{observable[2]}}</p> i.e get the array element in index 2 held by the observable 回答1: According to previous answers. You should avoid 2 things (if possible): Manual .subscribe() . Use async pipe instead so it will manage subscription for you. Internal state like .subscribe(val => this.val = val)