我是Ionic的新手。我的打字稿文件是這樣的:Ionic 2:在應用程序內部加載外部內容
import { Component } from '@angular/core';
import { Http } from '@angular/http';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-about',
templateUrl: 'about.html'
})
export class AboutPage {
mypage: any;
constructor(public navCtrl: NavController, public http: Http) {
this.http
.get('http://localhost/xampp/')
.map(response => response.text())
.subscribe(html => this.mypage = html);
}
}
任何URL,甚至在同一來源,會導致這樣的錯誤:
EXCEPTION: Response with status: 0 for URL: null
的錯誤出現在是離子的發球局中我的電腦或我的電話。我該怎麼做才能解決? 我想也加載它作爲組件「templateUrl:'somehtml'」,但將來我想在我的應用程序中加載一些JSON數據。謝謝。
我想你會很難搭上從GET請求中獲得完整的URL。存在一些嚴重的安全風險。我會很驚訝,即使你確實得到它的工作,它會被應用程序商店所接受。如果它自己的代碼庫,那麼你需要創建一個Api,它將與GET請求 – 2017-02-04 08:21:37
交互我有它(一個SOAP和一個REST webservice);這僅僅是爲了學習的目的。應該遵循的路線是什麼?它是不同的,如果我想加載模板或一些JSON數據或數組? –