我创建科尔多瓦插件离子2.我可以从Android DATAS,并显示在控制台或警报,但我不能表现出来的HTML视图。创建科尔多瓦插件与角2
device: any[] = [];
constructor(public navCtrl: NavController,
private appService: AppService) {
}
ngOnInit(): void {
devices_activity.devicesActivity(this.success, this.failure);
}
success(aL) {
for (var i = aL.length - 1; i >= 0; i--) {
aL[i];
console.log('name: ' + aL[i]);
}
}
failure() {
alert("Error calling Devices Stone SDK Plugin");
}
我试图把aL
在device
数组,但我得到了一个错误:ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'device' of null
我怎么能显示HTML视图从Android的收到货物?
哪里是你的HTML?这看起来不像是Ionic/Cordova问题,而是Angular 2问题。如果这些变量在您的控制台日志中发生,那么您可能只是没有在角度组件和模板之间正确地绑定变量。也许如果成功函数做了像aL = device这样的东西,我会看到你将模板中的两个方向绑定到了哪里,但是看起来你的代码并没有处理那些我能看到的东西,猜测是你的问题,如果这是有道理的 – chairmanmow
我试图做一个L =设备,但我得到了一个错误。它说'设备为空' –
对不起,我的不好,我翻转了该赋值语句。如果是设备=人 – chairmanmow