我在使用AngularFire2的Angular应用程序中有以下代码.
打字稿:
constructor(db: AngularFirestore) {
this.booksCollectionRef = db.collection<Book>('books');
this.books = this.booksCollectionRef.snapshotChanges().map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Book;
const id = action.payload.doc.id;
return { id, ...data };
});
});
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<md-list>
<md-list-item *ngFor="let book of books | async">
<h4 md-line>{{book.name}}</h4>
</md-list-item>
</md-list>
Run Code Online (Sandbox Code Playgroud)
此代码按预期检索和绑定数据(在更新集合时删除项目),现在我想按给定列对集合进行排序.我试图使用firebase orderBy子句,但我无法弄清楚如何使用它与snapShotChanges()
方法.
firebase typescript angularfire2 angular google-cloud-firestore
我已经使用angular2 CLI设置了反向代理,如下所示:
{
"/api/customer/*": {
"target": "http://localhost:9010",
"secure": false
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是远程API在路径/客户上公开服务,但反向代理发送的请求在/ api/customer上.
有没有办法从反向代理发送的请求中删除/ api?(不要回答"只需从你的http请求中删除/ api",因为我在/ customer上有一个有角度的路由).
谢谢,
纳米