我正在尝试从我的api中提取数据,并在我的离子应用程序中填充它,但是当我进入页面时应该填充数据时它会崩溃.以下是我的两个.ts文件:
import { Component } from '@angular/core';
import { NavController, LoadingController } from 'ionic-angular';
import { RestService } from '../../providers/rest-service/rest-service';
@Component({
selector: 'page-all-patients',
templateUrl: 'all-patients.html',
providers: [RestService]
})
export class AllPatientsPage {
data: any;
loading: any;
constructor(public navCtrl: NavController, public restService: RestService, public loadingCtrl: LoadingController) {
this.loading = this.loadingCtrl.create({
content: `
<ion-spinner></ion-spinner>`
});
this.getdata();
}
getdata() {
this.loading.present();
this.restService.getJsonData().subscribe(
result => {
this.data=result.data.children;
console.log("Success: " + this.data);
},
err => {
console.error("Error : " + err);
},
() => { …Run Code Online (Sandbox Code Playgroud) 使用Hapi v17,我只是想创建一个简单的Web API来开始构建我的知识,但每次测试构建的GET方法时我都会遇到错误.以下是我正在运行的代码:
'use strict';
const Hapi = require('hapi');
const MySQL = require('mysql');
//create a serve with a host and port
const server = new Hapi.Server({
host: 'serverName',
port: 8000
});
const connection = MySQL.createConnection({
host: 'host',
user: 'root',
password: 'pass',
database: 'db'
});
connection.connect();
//add the route
server.route({
method: 'GET',
path: '/helloworld',
handler: function (request, reply) {
return reply('hello world');
}
});
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});
Run Code Online (Sandbox Code Playgroud)
以下是我得到的错误:
Debug: internal, …Run Code Online (Sandbox Code Playgroud) 我试图将我的Ionic应用程序作为ios本机应用程序运行,并且遇到一个奇怪的URL连接错误,该错误阻止数据填充到我的应用程序视图中。当我以iphone的形式在网络浏览器中运行该应用程序时,它可以正常运行并填充,但是在本机ios上运行时,它并没有使用API数据按预期填充页面。我已经检查了控制台,实际上已经调用了API,但是xcode控制台正在打印出填充页面数据的2个API调用的以下内容:
2018-02-19 11:30:21.199933-0500 MyApp[1429:350591] NSURLConnection finished with error - code -1100
2018-02-19 11:30:21.202556-0500 MyApp[1429:350591] NSURLConnection finished with error - code -1100
Run Code Online (Sandbox Code Playgroud)
我已经看到并看到代码-1100通常是一个找不到文件的问题类型,但是我不确定这将如何发生,因为它只是通过API调用返回数据,然后将其存储在离子卡格式。
我试图创建一个离子应用程序,当我在离子创建器中将页面链接在一起时,.ts文件出现错误,如下所示:
typescript: src/pages/home/home.ts, line: 4
Individual declarations in merged declaration 'HomePage' must be all exported or all local.
L3: import { NotificationsPage } from '../notifications/notifications';
L4: import { HomePage } from '../home/home';
L5: import { MyPatientsPage } from '../my-patients/my-patients';
Run Code Online (Sandbox Code Playgroud)
以下是我的.ts文件中的代码:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NotificationsPage } from '../notifications/notifications';
import { HomePage } from '../home/home';
import { MyPatientsPage } from '../my-patients/my-patients';
import { AllPatientsPage } from '../all-patients/all-patients';
import { LoginPage } …Run Code Online (Sandbox Code Playgroud)