Hi. It’s possible adapt this Ionic 2 project to Ionic 1, or something similar, and instead of using ionic native camera, use ngCordova camera? I’m trying to implement this code on my camera page. I researched several sources, but I did not find anything similar for Ionic 1. What’s the best way to do this?
This is my page.ts
import {Component} from '@angular/core';
import {NavController, AlertController} from 'ionic-angular';
import {Camera, CameraOptions} from '@ionic-native/camera';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public photos : any;
public base64Image : string;
constructor(public navCtrl : NavController, private camera : Camera, private alertCtrl : AlertController) {}
ngOnInit() {
this.photos = [];
}
deletePhoto(index) {
let confirm = this
.alertCtrl
.create({
title: 'Sure you want to delete this photo? There is NO undo!',
message: '',
buttons: [
{
text: 'No',
handler: () => {
console.log('Disagree clicked');
}
}, {
text: 'Yes',
handler: () => {
console.log('Agree clicked');
this
.photos
.splice(index, 1);
//return true;
}
}
]
});
confirm.present();
}
takePhoto() {
const options : CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this
.camera
.getPicture(options)
.then((imageData) => {
this.base64Image = "file://" + imageData;
this
.photos
.push(this.base64Image);
this
.photos
.reverse();
}, (err) => {
console.log(err);
});
}
}
and this is my page.html
<ion-content padding class="card-background-page">
<button ion-button full (click)='takePhoto()'><ion-icon name="camera"></ion-icon></button>
<ion-grid>
<ion-row>
<ion-col col-6 *ngFor="let photo of photos; let id = index">
<ion-card class="releative">
<ion-icon ios="ios-add-circle" md="md-add-circle"class="deleteIcon" (click)="deletePhoto(id)"></ion-icon>
<img [src]="photo" *ngIf="photo" />
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
Thank you if you help me!