Ionic 2/TypeScript Promises List of dynamic functions

I’m new to typescript and Ionic 2, I’m trying to create a clean code, to take multiple images and convert to base64, so I’ll need to use “Promises”, my final goal is to get this list of base64 images and send them to my server. As I am working with heavy code I would like to make it very clean and that works, I would like to know everyone’s opinion, Thank you. My function to get the pictures is the getImgs().

However Promise.All never called.

I can not figure out what I’m missing, everything seems right.

import { Component } from '@angular/core';
import { NavController, NavParams, ModalController } from 'ionic-angular';
import { ImagePicker } from 'ionic-native';

  selector: 'page-cadastrar-post',
  templateUrl: 'cadastrar-post.html'
export class CadastrarPostPage {

  imgs: Array<any> =[];

  constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController) {


  ionViewDidLoad() {
    console.log('ionViewDidLoad CadastrarPostPage');

  convertFileToDataURLviaFileReader(url) {
    return new Promise(function (resolve, reject) {
      var xhr = new XMLHttpRequest();
      xhr.onload = function () {
        var reader = new FileReader();
        reader.onloadend = function () {
          // callback(reader.result);
      };'GET', url);
      xhr.responseType = 'blob';

  getImgs() {

    var options = {
      maximumImagesCount: 5,
      quality: 80

    ImagePicker.getPictures(options).then((results) => {

      for (var i = 0; i < results.length; i++) {

    }, (err) => { });

    Promise.all(this.imgs).then((results: any[]) => {



I’d guess there’s something wrong with the data url conversion code, it looks iffy. You should put the pass the promise reject as the error callback.

What does this.imgs contain when you get to promise.all?