Angular 2 - Sort list from Observable

让人想犯罪 __ 提交于 2019-12-03 05:03:14

If you call .subscribe() you get a Subscription, the async pipe expects an Observable.

If you change it to

this.test$ = Observable.of(['one', 'two', 'three'])
.map((data) => {
    data.sort((a, b) => {
        return a < b ? -1 : 1;
     });
    return data;
 });

you can use the async pipe with test$

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!