File
Metadata
| selector |
page-update-image-profile |
| templateUrl |
update-image-profile.html |
Constructor
constructor(navCtrl: NavController, navParams: NavParams, upSvc: UploadService, zone: NgZone)
|
|
|
Parameters :
| Name |
Type |
Optional |
Description |
| navCtrl |
NavController
|
|
|
| navParams |
NavParams
|
|
|
| upSvc |
UploadService
|
|
|
| zone |
NgZone
|
|
|
|
Methods
|
displayImage
|
displayImage(uidContact: )
|
|
|
Parameters :
| Name |
Type |
Optional |
Description |
| uidContact |
|
|
|
|
|
fileChange
|
fileChange(event: )
|
|
|
Parameters :
| Name |
Type |
Optional |
Description |
| event |
|
|
|
|
|
ionViewDidLoad
|
ionViewDidLoad()
|
|
|
|
|
|
uploadSingle
|
uploadSingle()
|
|
|
|
|
|
Private
event
|
event: any
|
Type : any
|
|
|
|
Private
image
|
image: any
|
Type : any
|
|
|
|
Public
navCtrl
|
navCtrl: NavController
|
Type : NavController
|
|
|
|
Public
navParams
|
navParams: NavParams
|
Type : NavParams
|
|
|
|
Private
selectedFiles
|
selectedFiles: FileList
|
Type : FileList
|
|
|
import { Component, NgZone } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { UploadModel } from '../../models/upload';
import { UploadService } from '../../providers/upload-service/upload-service';
@IonicPage()
@Component({
selector: 'page-update-image-profile',
templateUrl: 'update-image-profile.html',
})
export class UpdateImageProfilePage {
private event: any;
private uidContact: string;
private currentUpload: UploadModel;
private image: any;
//private imageurl: string;
private selectedFiles: FileList;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
private upSvc: UploadService,
public zone: NgZone
//private events: Events
) {
// recupero event
this.event = navParams.get('event');
this.uidContact = navParams.get('uidContact');
// imposto immagine per anteprima
if(this.event){
this.selectedFiles = this.event.target.files;
this.fileChange(event);
}
else{
this.displayImage(this.uidContact);
}
}
ionViewDidLoad() {
console.log('ionViewDidLoad UpdateImageProfilePage');
}
displayImage(uidContact){
this.upSvc.display(uidContact)
.then((url) => {
this.zone.run(() => {
this.image = url;
});
})
.catch((error)=>{
console.log("error::: ",error);
});
}
fileChange(event){
if(event.target.files && event.target.files[0]){
let reader = new FileReader();
reader.onload = (event:any) => {
this.image = event.target.result;
}
reader.readAsDataURL(event.target.files[0]);
}
//let fileList: FileList = event.target.files;
//let file: File = fileList[0];
}
uploadSingle() {
var send_order_btn = <HTMLInputElement>document.getElementById("start-upload");
send_order_btn.disabled = true;
let file = this.selectedFiles.item(0)
this.currentUpload = new UploadModel(file);
this.upSvc.pushUpload(this.currentUpload)
}
goBack(){
this.navCtrl.pop({animate: true, duration: 0.3});
}
}
<!--
Generated template for the UpdateImageProfilePage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title *ngIf="!uidContact">Salva immagine profilo</ion-title>
<ion-title *ngIf="uidContact">Immagine del profilo</ion-title>
<ion-buttons left>
<button ion-button icon-only (click)="goBack()">
<ion-icon name="close"></ion-icon>
</button>
</ion-buttons>
<ion-buttons *ngIf="!uidContact" right>
<button id="start-upload" ion-button icon-only clear class="button button-check" (click)="uploadSingle()">
<ion-icon name="checkmark-circle"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding>
<div class="preview">
<img *ngIf="image" class="image-profile" [src]="image"/>
<div id="progress" *ngIf="currentUpload && currentUpload.progress!=100">caricamento...{{this.currentUpload.progress}}%</div>
<div id="ok_message" *ngIf="currentUpload && currentUpload.progress==100">CARICAMENTO COMPLETO
<br/>
<button ion-button (click)="goBack()">
chiudi
</button>
</div>
<!-- {{this.currentUpload.progress}} -->
</div>
</ion-content>
Legend
Html element with directive