Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Angular hide button while loading then re enable

I have a component that loads an image when the button is clicked.

To avoid multiple clicks, I want to hide the button when clicked, display a text and re enable the button when the image is loaded.

I'm not sure why this code doesn't work.

Here's the html file:

<div class="row">
    <img [src]="url ? url : 'assets/image/evolution_s.png'" class="gan_generated mx-auto d- 
     block" alt="it is sad :'(">
    <img [src]="url ? url : 'assets/image/evolution_s.png'" class="gan_generated mx-auto d- 
     block" alt="it is sad :'(">
</div>
<div *ngIf="this.isClicked==false else waitBlock">
  <button type="button"
          class="btn btn-outline-primary mx-auto d-block"
          (click)="generate_and_show()">Generate Anime Faces</button>
</div>
<ng-template #waitBlock><p class="text-center">Please wait for the artist</p></ng-template>

and here's the component.ts:

export class GanComponent implements OnInit {
    public isClicked = false;

    constructor(private ganService: ImageGanService,
          private sanitizer: DomSanitizer) {
    }

    url: SafeUrl;

    ngOnInit(): void {
    }

    generate_and_show(): void {
        this.isClicked = true;
        this.ganService.request_image()
        .subscribe(response => {
          this.url = 
          this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(response));
        });
        this.isClicked = false;
    }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda