【发布时间】:2019-07-14 08:56:59
【问题描述】:
我正在将我的应用从 Angular 3 迁移到 Angular 7,
离子 3 到离子 4
有两个服务BaseHttpService主要负责Http调用和AppService扩展BaseHttpService进行调用。
在迁移Docs中,提到在服务中使用{ providedIn: "root" }。
但是没有提到服务中的基类和父类。我尝试了很多方法但没有通过。
我有一个父服务,它有一些依赖项,例如
export abstract class BaseHttpService implements OnInit {
private baseUrl: string = Constants.BASEURL;
protected method: string;
protected serviceUrl: string;
protected headers: Headers;
constructor(private http:) {
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json')
this.headers.append('Accept', 'application/json');
}
}
我想扩展服务
@Injectable({ providedIn: "root" })
export class AppService extends BaseHttpService{
constructor(private _http: Http, ) {
super(_http);
}
但在浏览器上运行时抛出错误
【问题讨论】:
-
(private http:) 无类型!!
-
有什么例外?
-
请查看此示例链接:这可能对您有帮助。 how to extend service with dependencies in angular 2
-
@GhoulAhmed 这是重复参数属性,不是类型,这是问题的一部分; 访问修饰符是需要删除的。
-
这是为 Angular 7 而不是 2。我正在迁移到 Angular 7
标签: javascript angular ionic-framework ionic4