I have one issue in my app.
I have a var array in ts, and in html I have list with one for and paint this array.
When I add text automatly the html refresh and paint one line more, the problem is when I use getPicture ( camara plugin ) to get image of gallery and add this to array, everything works correctly, but the html not refresh, when I click in another section automatly refresh the html.
If I only add text when I pick image the same thing happen, I think getpicture “blocks” the refresh of app.
Anyone know the way to force “refresh” of page, or any solution to this issue?
Thx
import { IonicPage, NavController, NavParams, AlertController, ModalController } from 'ionic-angular';
import { Component } from '@angular/core';
@IonicPage()
@Component({
selector: 'page-chat-chat',
templateUrl: 'chat.html',
})
export class ChatPage {
hilos: any;
constructor(public navCtrl: NavController, public alertCtrl: AlertController, public navParams: NavParams, public http: HttpProvider, public global: GlobalProvider, public modalCtrl: ModalController) {
}
addFile(file) {
navigator["camera"].getPicture(
function(uri){
this.hilos.unshift({"ID":new Date().getTime(),"TYPE":"FILE","TEXT":uri,"SIZE":""});
},
function(message){
//alert("alert",'Failed because: ' + message);
},
{
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA, //Camera.PictureSourceType.SAVEDPHOTOALBUM
correctOrientation: true,
saveToPhotoAlbum: true,
targetWidth: 800,
targetHeight: 800
}
);
}
<ion-list>
<ion-card *ngFor="let h of hilos">
<ion-card-content>
<ion-list>
<ion-item class="body">
<span *ngIf="h.TYPE == 'TEXT'" class="text">{{h.TEXT}}</span>
<span *ngIf="h.TYPE == 'IMAGE' && h.IMAGE == undefined" class="text"><img src='{{h.TEXT}}'></span>
<span *ngIf="h.TYPE == 'IMAGE' && h.IMAGE != undefined" class="text"><img src='{{h.IMAGE}}'></span>
<div class="file" *ngIf="h.TYPE == 'FILE'">
<img src='../../assets/images/adjuntos/{{h.TEXT.split(".").pop()}}.png'>
<span class="texto">{{h.TEXTO.split("/").pop()}}</span>
</div>
</ion-item>
</ion-list>
</ion-card-content>
</ion-card>
</ion-list>