angular 管道和水龙头未触发功能
function not fired from angular pipe and tap
我正在尝试在我的登录服务中调用一个函数。用过的水管和水龙头。当我执行 res => console.log(res)
时,我得到了输出。但是当我尝试调用一个函数时,调用没有到达函数体 res => this.setSession
。下面是完整的代码。
import { Injectable } from '@angular/core';
import { APIService } from '../api.service';
import { tap, shareReplay } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class LoginService extends APIService{
loginUser(logindata){
console.log('oh yeah')
return this.httpClient.post(`${this.API_URL}/rest-auth/login/`, logindata)
.pipe(tap(res => this.setSession));
}
private setSession(authResult) {
console.log('Not coming here')
}
}
你从不调用方法。使用 ()
:
.pipe(
tap(res => this.setSession())
); // add this ---^
我正在尝试在我的登录服务中调用一个函数。用过的水管和水龙头。当我执行 res => console.log(res)
时,我得到了输出。但是当我尝试调用一个函数时,调用没有到达函数体 res => this.setSession
。下面是完整的代码。
import { Injectable } from '@angular/core';
import { APIService } from '../api.service';
import { tap, shareReplay } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class LoginService extends APIService{
loginUser(logindata){
console.log('oh yeah')
return this.httpClient.post(`${this.API_URL}/rest-auth/login/`, logindata)
.pipe(tap(res => this.setSession));
}
private setSession(authResult) {
console.log('Not coming here')
}
}
你从不调用方法。使用 ()
:
.pipe(
tap(res => this.setSession())
); // add this ---^