我是angualr 2的新手。我正在为练习做一个小应用。我有一个登录用户身份验证服务。这里是登录功能。订阅不存在“订阅”类型
login(email:string, password:string){
var loginrul="https://filing.herokuapp.com/api/v1/auth/login/";
return this.http.post(loginrul,JSON.stringify({ password: password,email: email }),
{headers:new Headers({'Content-Type':'application/json'})}
).map(res=>res.json()).
subscribe(
data => localStorage.setItem('id_token',data.auth_token),
error=>console.log(error)
);
}
当我调用该函数在组件angualr给出错误“房产认购上键入‘认购’不存在。
doLogin(event) {
console.log(event);
console.log(this.loginForm.value);
let formData = this.loginForm.value;
let email = this.loginForm.controls.email.value;
let password= this.loginForm.controls.password.value;
this.auth.login(email,password).subscribe(res =>{
console.log(res);
if(res.status===200){
this.router.navigate(['dashboard']);
}
}
)
}
我想是因为我使用订阅为什么角是给这个错误在登录功能以及呼叫登录功能的同时,请提供一些解决方案或替代方法来实现我在登录功能中试图实现的结果
只要返回地图()并订阅调用者 – Fals