我正在使用Ionic创建iOS和Android应用程序,我有一个列表视图,显示网站名称和来自json文件的URL。我正在显示json,但我在iPhone上的DevApp测试中遇到错误。它说我的json不能GET / myURLString。它显示url字符串。
这就是我所拥有的。有人可以帮助,我连接到wifi和地址栏中的网址说我点击列表视图项目后。本地主机:8102 / www.myjsonblahblah.net
my resources.html
<ion-header>
<ion-navbar>
<ion-title>Resources & Information</ion-title>
</ion-navbar>
</ion-header>
<ion-item><p text-wrap>Our Resources page will offer adding new resources and finding a team your area.</p></ion-item>
<ion-buttons>
<button ion-button full large color="secondary" style="color: #000000;">Add a resource!</button>
<button ion-button full large color="secondary" style="color: #000000;">Find a team in your area!</button>
</ion-buttons>
<ion-list>
<button ion-item detail-none *ngFor="let item of filteredList" (click)="openWebpage(item.post.URL)">
<h4 text-wrap>{{item.post.Name}}</h4>
<p>{{item.post.URL}}</p>
</button>
</ion-list>
</ion-content>
我的resource.ts文件
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { DataProvider } from '../../providers/data/data';
import { InAppBrowser, InAppBrowserOptions } from "@ionic-native/in-app-browser";
@IonicPage()
@Component({
selector: 'page-resources',
templateUrl: 'resources.html',
})
export class ResourcesPage {
url: any;
tournments: any[];
filteredList = [];
listType = 'all';
constructor(
private navCtrl: NavController,
private dataProvider: DataProvider, private inAppBrowser: InAppBrowser) {
this.dataProvider.getResource().subscribe((data: any) => {
this.tournments = data.posts;
this.filteredList = this.tournments;
this.url = data.posts;
});
}
openWebpage(url: string) {
const options: InAppBrowserOptions = {
zoom: 'yes',
toolbar: 'yes',
enableViewportScale: 'yes',
}
// Opening a URL and returning an InAppBrowserObject
const browser = this.inAppBrowser.create(url, '_system', options);
console.log(url);
console.log(browser);
console.log("link viewed");
// Inject scripts, css and more with browser.X
}
/**
* open Resoures detail page
*
* @param tournament
*/
openResourcePage(tournament: any) {
this.navCtrl.push('ResourceDetailPage', {tournament: tournament});
}
/**
* search by text
*/
onSearch(event: any) {
const searchText = event.target.value.toLowerCase();
this.filteredList = this.tournments.filter(item => {
if ((item.post.NAME as string).toLowerCase().indexOf(searchText) > -1) {
return true;
}
return false;
});
}
segmentChanged(event: any) {
this.dataProvider.getResource(event.value).subscribe((data: any) => {
this.tournments = data.posts;
this.filteredList = this.tournments;
});
}
}