从AngularFire中观察到的Angular模板中的ID用户不起作用
我具有通过ID获取用户的功能,但总是可以返回可观察的,但是我的问题是,我必须将ID传递给函数表格模板以获取我想要的数据,因为该功能不是我不知道的普通函数如何在角度做到这一点。
/user.service
returnuserbyid(id) {
const noteDocRef = doc(this.fs, `users/${id}`);
return docData(noteDocRef, { idField: 'id' }) as Observable<any>;
/user.page
getuser(id) {
this.userservice.returnuserbyid(id).subscribe((res) => {
this.user = res;
});
我希望能够将ID传递给模板内的Getuser函数并获取用户的详细信息。我目前正在使用Angular Fire 7
i have the function to get user by id but it always return observable, but my problem is i have to pass and id to the function form the template in order to get the data i want, since the function isnt an ordinary one i dont know how to do that in angular.
/user.service
returnuserbyid(id) {
const noteDocRef = doc(this.fs, `users/${id}`);
return docData(noteDocRef, { idField: 'id' }) as Observable<any>;
/user.page
getuser(id) {
this.userservice.returnuserbyid(id).subscribe((res) => {
this.user = res;
});
i want to be able to pass pass an id to the getuser function inside my template and get the details of the user. i an currently using angular fire 7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以通过firebase
通过ID检索用户,
默认定义的ID,则使用了第一个方法。
字段)
There are two ways to retrieve a user through the id with firebase
the first one if it is an id defined by default by firebase
if you give an id to the user yourself (this id is part of the user
field)