更新时间:2022-06-10 21:57:41
仅通过声明public http: Http
不会使Http
提供程序实例在组件内部可用.您必须将http
服务注入构造函数中,这将带来http
对象.
Just by declaring public http: Http
will not make Http
provider instance available inside component. You have to inject http
service inside constructor, that will bring http
object.
public constructor(
private marginService: MarginServcies,
private http: Http //<-- added Http service.
) {
//your code as is
}
从中删除
public http: Http
(http声明)的声明public http: Http
Remove the declaration of
public http: Http
(http declaration) from start of classpublic http: Http