im在ionic2本机中使用fileOpener
doc在这里。
这是我的代码:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FileOpener } from 'ionic-native';
@Component({
selector: 'page-installHelper',
templateUrl: 'installHelper.html'
})
export class InstallHelper {
constructor(public navCtrl: NavController, public fo: FileOpener) {
fo.open('/assets/app.apk', 'application/vnd.android.package-archive');
}
}
,但它给出一个错误,说: Property 'open' does not exist on type 'FileOpener'.
我想从我的应用程序打开一个APK文件。
带有本机组件,您不将其分配给构造函数。
,您的代码应该看起来像:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FileOpener } from 'ionic-native';
@Component({
selector: 'page-installHelper',
templateUrl: 'installHelper.html'
})
export class InstallHelper {
constructor(public navCtrl: NavController) {
FileOpener.open('/assets/app.apk', 'application/vnd.android.package-archive',
{
error : (e)=> {console.log('Error status: ' + e.status + ' - Error message: ' + e.message);},
success : ()=> {console.log('file opened successfully');}
});
}
}