微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误TypeError:无法读取未定义的属性“登录”

如何解决错误TypeError:无法读取未定义的属性“登录”

我正在尝试使用登录功能,但出现此错误 https://image.noelshack.com/fichiers/2020/40/6/1601742042-1.jpg

登录功能代码

onSubmit(){
console.log(this.form)
this.Jarwis.login(this.form).subscribe(
    data => {this.handleResponse(data)
   console.log(data)},error => this.handleError(error)
 )
 }

jarwis服务代码

export class JarwisService {
constructor(private http:HttpClient) { }

apiUrl="http://127.0.0.1:8000/api/auth"
public login(data){
return this.http.post(`${this.apiUrl}/login`,data);
}}

最后,这是我的登录组件代码+我的角度架构师代码https://image.noelshack.com/fichiers/2020/40/6/1601742370-2.jpg

解决方法

您可以确定您的服务可以注射吗?

import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',})
export class HeroService {
  constructor() { }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。