我正在使用Angular和firebase构建应用程序(使用AngularFire2)。当尝试在任何firebase observable(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
答案 0 :(得分:2)
您没有导入AngularFireAuth(以前称为FirebaseAuth)
equals