我是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数据或数组? –