Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
http无法返回4中的html内容_Html_Angular - Fatal编程技术网

http无法返回4中的html内容

http无法返回4中的html内容,html,angular,Html,Angular,我正在使用angular4,试图将html模板加载到页面中 this.http.get("/assets/abc.html") .subscribe( (data) => { console.log("--------------"+data); } ); http的结果不是返回html内容,而是只返回如下所示的页面路径 --------------Response with status: 200 OK for URL: http://localho

我正在使用angular4,试图将html模板加载到页面中

this.http.get("/assets/abc.html")
  .subscribe(
    (data) => {
      console.log("--------------"+data);
    }
  );
http的结果不是返回html内容,而是只返回如下所示的页面路径

--------------Response with status: 200 OK for URL: http://localhost:4200/assets/abc2.html

如何获得真正的内容

使用以下内容提取响应的内容:

this.http.get("/assets/abc.html")
  .subscribe( res => {
      console.log(res.text());
    }
  );

使用以下命令提取响应的内容:

this.http.get("/assets/abc.html")
  .subscribe( res => {
      console.log(res.text());
    }
  );

在订阅中得到的是响应对象。要获取实际数据,请尝试以下操作:

this.http.get("/assets/abc.html")
  .subscribe(
    (response) => {
      console.log(response.text());
    }
  );

在订阅中得到的是响应对象。要获取实际数据,请尝试以下操作:

this.http.get("/assets/abc.html")
  .subscribe(
    (response) => {
      console.log(response.text());
    }
  );

啊,同一时间同一个答案*击掌*让我们互相投票:)谢谢老兄,这里也一样啊,同一时间同一个答案*击掌*让我们互相投票:)谢谢老兄,这里也一样