Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
How do I make Origin and Preview have the same photo, and when imageCropped($event) in Preview, only that photo changes?

I am using image-cropper on an angular project.

Documentation: https://www.npmjs.com/package/ngx-image-cropper

There are several images on the page, which are loaded by the loop *ngIf="field.type === 'images'" and displayed in the image-cropper tag in [imageURL] . The images are displayed correctly in Origin, but the Preview field randomly displays different photos. When (imageCropped)="imageCropped($event)" event in all Preview changes to the changed photo.

How do I make Origin and Preview have the same photo, and when imageCropped($event) in Preview, only that photo changes?

import { Component } from '@angular/core';

import { ImageCroppedEvent } from 'ngx-image-cropper';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'angular-image-uploader';

    imageChangedEvent: any = '';
    croppedImage: any = '';

    fileChangeEvent(event: any): void {
        this.imageChangedEvent = event;
    }
    imageCropped(event: ImageCroppedEvent) {
        this.croppedImage = event.base64;
    }
    imageLoaded() {
        // show cropper
    }
    cropperReady() {
        // cropper ready
    }
    loadImageFailed() {
        // show message
    }
}
<div class="edit-window__wrapper" *ngIf="field.type === 'images'">
  <div class="edit-window__origin">
    <p>Origin</p>
    <image-cropper
      [imageURL]="imageComplexForm.controls[field.fields.file.key].value.path"
      [maintainAspectRatio]="false" 
      [aspectRatio]="4 / 4"
      [resizeToWidth]="256" 
      format="png"
      (imageCropped)="imageCropped($event)" 
      (imageLoaded)="imageLoaded()"
      (cropperReady)="cropperReady()" 
      (loadImageFailed)="loadImageFailed()"
    ></image-cropper>
  </div>
  <div class="edit-window__preview>
    <p>Preview</p>
    <img [src]="croppedImage" />
  </div>
</div>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!