Я пытаюсь подключить свое устройство к серверу Linux через IP.Но если я хочу запустить приложение, я просто получаю белый экран ... План состоит в том, чтобы нажать кнопку на экране home.html и подключиться к устройству Linux.
ошибка также возникает, если я неНе добавляйте функцию conToServe () в html-документ.
home.ts:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { DataPage } from '../data/data';
var socket= new socket();
socket.onData = function(data) {
// invoked after new batch of data is received (typed array of bytes Uint8Array)
};
socket.onError = function(errorMessage) {
// invoked after error occurs during connection
};
socket.onClose = function(hasError) {
// invoked after connection close
};
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
navToPage(pageName: string) {
pageName === 'TabsPage' ? this.navCtrl.setRoot(pageName) : this.navCtrl.push(pageName);
}
conToServ() {
socket.open(
"192.168.131.243",
22,
function() { console.log("login succesfull")
// invoked after successful opening of socket
},
function(errorMessage) { console.log("unsuccessfull login")
// invoked after unsuccessful opening of socket
});
if (socket.state == socket.State.OPENED) {
console.log("Socket is opened");
}
}
}
home.html:
<ion-content padding="10px" class="startBackground">
<div class="homeContainer">
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-5"></div>
<div class="homeBox homeBox-4" align-items="center">
<img ion-img src="assets/imgs/startbuttontext.png" width="auto" align-items="center" (click)="navToPage('TabsPage')" (click)="conToServe">
</div>
<div class="homeBox homeBox-5"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-1"></div>
<div class="homeBox homeBox-2">Impressum</div>
<div class="homeBox homeBox-3"></div>
<div class="homeBox homeBox-6">
<img ion-img src="assets/imgs/logo.png" width="90%" height=auto>
</div>
</div>
</ion-content>