- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 Angular 和 firebase(使用 AngularFire2)构建一个应用程序。尝试在任何 firebase 可观察对象(FirebaseAuthObservable、FirebaseListObservable)上使用 .map 运算符时出现错误
[s] Supplied parameters do not match any signature of call target. (property) AngularFire.auth: AngularFireAuth
这是我的代码
import { Component, OnInit } from '@angular/core';
import { AngularFire } from 'angularfire2'
import { Router, ActivatedRoute } from '@angular/router';
import {Observable } from 'rxjs/Observable';
import 'rxjs/Rx';
@Component({
selector: 'app-edit-objective',
templateUrl: './edit-objective.component.html',
styleUrls: ['./edit-objective.component.css']
})
export class EditObjectiveComponent implements OnInit {
constructor(private af: AngularFire, private route: ActivatedRoute, public router: Router) { }
ngOnInit() {
this.af.auth
.map((x) => {})
.subscribe(y => console.log(y))
}
}
我在这里遗漏了什么吗?
编辑**
我试过只创建一个新的 Observable 并在其上使用 map 运算符,但这也不起作用。
import { Component } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor() {
let x: Observable<string> = Observable.create(observer => {
observer.next('test');
})
x.map(str => str + " "); //Error on this line (see below)
}
}
我得到的错误是:
[ts] Supplied parameters do not match any signature of call target.
pplies a given project function to each value emitted by the source
Observable, and emits the resulting values as an Observable.
<span class="informal">Like Array.prototype.map(),
it passes each source value through a transformation function to get
corresponding output values.</span>
<img src="./img/map.png" width="100%">
Similar to the well known Array.prototype.map function, this operator
applies a projection to each value and emits that projection in the output
Observable.
@example <caption>Map every click to the clientX position of that click</caption>
var clicks = Rx.Observable.fromEvent(document, 'click');
var positions = clicks.map(ev => ev.clientX);
positions.subscribe(x => console.log(x));
@see {@link mapTo}
@see {@link pluck}
@return {Observable<R>} An Observable that emits the values from the source
Observable transformed by the given project function.
@method map
@owner Observable
最佳答案
您没有导入 AngularFireAuth(以前称为 FirebaseAuth)
import { AngularFireAuth } from 'angularfire2/auth';
...
export class EditObjectiveComponent implements OnInit {
constructor(private afAuth: AngularFireAuth) { }
ngOnInit() {
this.afAuth.authState
.map(x => x.uid)
.subscribe(x => console.log(x))
}
}
关于angular - map 运算符不适用于 AngularFireAuth Observable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43750718/
我想要一个包装 AngularFireAuth 服务的 AuthWrapper 服务。像这样。 // EDIT: Adding some import statements. import {Test
这个问题在这里已经有了答案: Firebase kicks out current user (19 个回答) 关闭 3 年前。 我使用带有 firebase 的 Angular 应用程序,并且我具
是否可以在 Firebase 中使用附加字段创建用户?在我的代码中,我可以使用“电子邮件”和“密码”创建它们。 this.af.auth.createUser({ name: formDa
我的 Angular 项目成功使用了 AngularFireAuth可从 @angular/fire 注入(inject)连接到本地 Firebase 身份验证模拟器。我使用这些资源作为我的实现的引用
我已更改官方 AngularJS 文档以使用 Firebase(手机教程)。 这是我的应用程序的路由器: angular.module('phonecat', ['firebase']). conf
我正在使用 Ionic4 和 @angular/fire 编写聊天应用程序代码,但在运行我的应用程序时出现白页和错误消息 (F12)。有人可以帮助我吗? 谢谢。 应用程序模块.ts import {
如何获取登录用户? 我正在这样做: console.log('正在登录...'); this.afAuth.auth.signInWithEmailAndPassword(this.email, th
亲爱的 stackoverflow 社区, 我有以下问题。我尝试将 FirebaseAuthentication 与 Angular7 一起使用,并尝试使用守卫保护路由,因此只有登录用户才能访问 /p
我有一个核心服务,它获取 firebase.auth obj 的实例并使用 getter 返回它。它很简单,如下所示: export class AuthService { ... const
我已经使用 AngularFire2 使用 jasmine/karma 为我的 Angular2 Web 应用程序创建了测试用例,但遇到了一个奇怪的错误,我无法调试。当我运行测试(检查应用程序组件是否
我有一个核心服务,它获取 firebase.auth obj 的实例并使用 getter 返回它。它很简单,如下所示: export class AuthService { ... const
我有一个 authService实例化时订阅 AngularFireAuth的可观察 authState并设置服务的内部(私有(private))属性authState . 所以我可以单元测试auth
有人知道 Angularfire 的新代码 - Angular 4 signInWithEmailAndPassword 方法吗? loginWithEmail(email: string, pass
我已经使用 Firebase 身份验证和 Cloud Fire Store 建立了一个新的 Angular 6 项目。有一个登录页面,您可以在其中通过谷歌登录,用户数据保存在 Firestore 中(
我正在使用 Angular 和 firebase(使用 AngularFire2)构建一个应用程序。尝试在任何 firebase 可观察对象(FirebaseAuthObservable、Fireba
抱歉,我想不出更好的方法来包含所有信息...当我运行它时,我收到一条错误消息,内容如下。我已经按照 Ionic Docs 到 T,我无法弄清楚可能出了什么问题。 错误: No provider for
我知道以前曾有人问过这个问题,但我见过的解决方案都不适合我。我使用 firebase-ui 为我的 ionic 应用程序构建一个登录页面,我使用与其他应用程序完全相同的方法,并且它在那里工作。我安装了
我们尝试使用(Firebase/ionic2/angularjs2)通过谷歌身份验证登录。我们的代码 import { Component } from '@angular/core'; impor
我正在尝试将 angularFireAuth(来自 AngularFire - Firebase)与 ui-route 结合使用。 问题是 angularFireAuth 需要 ng-route 作为
我一直在兜圈子,试图对依赖于 AngularFireAuth 的服务 (AuthService) 进行单元测试。 我正在尝试找到一种方法来模拟或劫持 Observable AngularFireAut
我是一名优秀的程序员,十分优秀!