Как я могу вызвать другую функцию внутри функции Cordova в Angular 8? - PullRequest
0 голосов
/ 05 ноября 2019

Привет, когда я пытаюсь использовать this.upload ();чтобы вызвать функцию загрузки из функции Cordova, я получаю эту ошибку enter image description here

Код

/* This is the cordova function to access the phone camera */
cameraTakePicture() {
  navigator.camera.getPicture(this.onSuccess, this.onFail, {
  quality: 50,
  destinationType: navigator.camera.DestinationType.DATA_URL,
  });
}
onSuccess(imageData) {
  const image: any = document.getElementById('myImage');
  image.src = 'data:image/jpeg;base64,' + imageData;
  this.selected = imageData;
  }
 onFail(message) {
    alert('Failed because: ' + message);
}
/* Upload function I am trying to call */
  Upload() {
    const file = new FormData();
    if (this.selected != null) {
    this.loading = true;
    if (this.mobile === true) {
      document.querySelector('#output').scrollIntoView({ behavior: 'smooth', block: 'center' });
      }
    file.append('file', this.selected, this.selected.name);
    this.env.upload(file).subscribe(
      data => {
        this.data = data;
        this.loading = false;
      },
      error => {
        this.loading = false;
      }
    );
    } else {
      this.notifiy.showInfo('You need to choose a file first', 'Info');
    }
  }

Я не уверен, как я могу вызвать эту функцию, любой совет был бы очень полезен, если бы кто-то мог объяснить, почему я получаю эту ошибку, которая была бы замечательной

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...