Javascript Angular 4 typescript Cordova摄像头插件错误“;财产';摄像机&x27;不存在于类型';导航器&x27&引用;
我正在尝试使用Cordova构建APK。Web部件代码是用Angular 4 typescript编写的。当ng构建时,它给了我以下错误 $/AngularCordova/my app/src/app/app.component.ts中的错误(19,26): 类型“Navigator”上不存在属性“camera”。错误 $/AngularCordova/my app/src/app/app.component.ts(23,13):提供 参数与调用目标的任何签名都不匹配 我在openCamera函数中替换了上面的代码。发生错误是因为我试图从窗口对象访问navigator对象Javascript Angular 4 typescript Cordova摄像头插件错误“;财产';摄像机&x27;不存在于类型';导航器&x27&引用;,javascript,android,angular,cordova,Javascript,Android,Angular,Cordova,我正在尝试使用Cordova构建APK。Web部件代码是用Angular 4 typescript编写的。当ng构建时,它给了我以下错误 $/AngularCordova/my app/src/app/app.component.ts中的错误(19,26): 类型“Navigator”上不存在属性“camera”。错误 $/AngularCordova/my app/src/app/app.component.ts(23,13):提供 参数与调用目标的任何签名都不匹配 我在openCamera函
import { Component, OnInit } from '@angular/core';
declare let cordova: any;
declare let navigator: any;
let device;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'angular app';
ngOnInit(){
this.deviceinfo();
}
deviceinfo(){
document.addEventListener('deviceready', () => {
alert("On device ready event");
try{
alert('Using Cordova plugins with Angular 4. Cordova version: ');
}catch(e){
alert("Exception occures"+ e)
}
}, false)
}
openCamera() {
if( window.navigator != undefined){
window.navigator.camera.getPicture(
(imageUri) => {
alert(imageUri);
},
(error) =>{
alert("Unable to obtain picture: " + error, "app");
}, {
quality: 50,
allowEdit: true,
correctOrientation: true //Corrects Android orientation quirks
}
);
}
}
}
if( navigator != undefined){
navigator.camera.getPicture(
(imageUri) => {
alert(imageUri);
},
(error) =>{
alert("Unable to obtain picture: "+error);
}, {
quality: 50,
allowEdit: true,
correctOrientation: true
}
);
}