Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Ionic v3, Array, Angular and Variables

$
0
0

@marcotrumpet wrote:

I need your help. In my app I want to display an array with *ngFor. My array is composed by a name field and a field that contain a variable with the base64 of an image. That variable is generated with Camanjs that makes async result.

    import { Component, NgZone } from '@angular/core';
    import { NavController, NavParams, AlertController } from 'ionic-angular';
    import { HomePage } from '../home/home';

    declare var Caman: any;
    @Component({
      selector: 'page-filtri',
      templateUrl: 'filtri.html'
    })
    export class FiltriPage {

    filtri = [];

    vintage: any;
    lomo: any;

      constructor(public navCtrl: NavController, public navParams: NavParams, alertCtrl: AlertController, public zone: NgZone) {

        this.filtri = [
          {
            nome: "Vintage",
            base: this.vintage,
          },
          {
            nome: "Lomo",
            base: this.lomo,
          }

        ];

      }

    ionViewDidLoad(){

      this.vintageFilter();
      this.lomoFilter();

    }

    vintageFilter(){

      let scope = this;

           Caman("#image", function () {
             this.revert();
             this.vintage();
             this.render(function () {
             scope.vintage = this.toBase64();
             });
           });
    }

    lomoFilter(){

      let scope = this;

           Caman("#image", function () {
             this.revert();
             this.lomo();
             this.render(function () {
             scope.lomo = this.toBase64();
             });
           });
    }
    }

… I delete some irrelevant stuff from my code.
I can display the “nome” from my array but not “base”.
I’m pretty sure that is something about promises but how can I solve this?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>