I am new to ionic/angular. In my edit profile page(different page), I can change the profile pic and it should reflect the same in main profile page(another page), these two pages are different.
HTML:
<ion-item lines="none">
<ion-avatar class="ion-align-self-left" id="pic" (click)="change()">
<img src="{{myphoto}}">
</ion-avatar>
</ion-item>
TS:
export class ProfilePage implements OnInit {
myphoto:any;
constructor(private camera: Camera) {
this.myphoto = '/assets/img/DP.svg';
this.statusBar.backgroundColorByHexString('#ffffff');
}
ngOnInit() {
}
take(){
this.ishide =true;
this.hide_input =false;
const options: CameraOptions = {
quality: 70,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.myphoto = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
}
get() {
this.ishide =true;
this.hide_input =false;
const options: CameraOptions = {
quality: 70,
destinationType: this.camera.DestinationType.DATA_URL,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
saveToPhotoAlbum:false
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
this.myphoto = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
}
}