【发布时间】:2018-06-01 01:24:24
【问题描述】:
我正在尝试使用 ionic 构建一个应用程序,该应用程序从本地“.json”文件中读取数据并使用这些数据来填充页面。但我已经在努力将文件导入页面。我目前拥有的是:
import { Component } from "@angular/core";
interface Entry {
name: string,
telephone: string
}
interface EntryList {
entryList: Array<Entry>;
}
@Component({
selector: 'page-list',
templateUrl: 'list.html'
})
export class ListPage {
entryList: EntryList;
constructor() {
this.load_entries();
};
load_entries () {
this.entryList = JSON.parse(
// ?
)
};
}
.json 文件包含以下条目:
[
{"name": "Person A","telephone": "1234"},
{"name": "Person B","telephone": "12345"}
]
我不知道如何从这里开始。将我的数据导入应用的正确方法是什么?
【问题讨论】:
标签: json angular cordova parsing ionic-framework