How to load external html page in ionic2

后端 未结 1 384
自闭症患者
自闭症患者 2021-01-15 20:29

I am creating an Ionic2 app. I have a component that I would like to load an external templateUrl into e.x (http:www.example.com/test-view.html).

How do I go about l

1条回答
  •  梦毁少年i
    2021-01-15 21:01

    You can do it like this:

    this.http
      .get('http://example.net//test-view1.html')
      .map(response => response.text())
      .subscribe(html => myVal = html);
    

    Note that html will be sanitized, so if you need something fancy you'll have to use DomSanitizationService. Don't forget about it's Security Risk flag in the docs (;

    0 讨论(0)
提交回复
热议问题