【问题标题】:Expected 0 arguments but got 1 in ionic 3 provider injectalble issue预期 0 个参数,但在 ionic 3 provider injectionalble 问题中得到 1 个
【发布时间】:2023-04-01 22:29:02
【问题描述】:

当我尝试从 Angular Web 应用服务的 ionic 提供程序中添加 api 连接部分时,它显示 Expected 0 arguments but got 1 in here:

@Injectable({
  providedIn: 'root'
})

虽然在 Angular Web 项目中也是如此。

Ionic3 提供程序如下所示:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';

const BASEURL = 'http://domain...';

@Injectable({
  providedIn: 'root'
})
export class AuthProvider {
  constructor(private http: HttpClient) { }

  RegisterUser(body): Observable<any> {
    return this.http.post(`${BASEURL}/register`, body);
  }

  LoginUser(body): Observable<any> {
    return this.http.post(`${BASEURL}/login`, body);
  }
}

如何解决这个问题?

【问题讨论】:

    标签: angular typescript ionic-framework ionic3 angular6


    【解决方案1】:

    改变这个:

    (Angular 6 中的新功能在 ionic 3 中不起作用)

    @Injectable({
     providedIn: 'root'
    })
    

    到这里

    @Injectable()
    

    升级到离子4

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-07
    • 2022-01-24
    • 2019-11-23
    • 2018-08-14
    • 1970-01-01
    • 2020-10-12
    • 2020-11-22
    • 2021-10-05
    相关资源
    最近更新 更多