且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

TypeError:无法读取未定义的属性"post"

更新时间: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 class public http: Http