0

I have created standalone component.

import { AsyncPipe, CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';

@Component({
  selector: 'app-cnn',
  standalone: true,
  imports: [CommonModule, FormsModule, AsyncPipe],
  templateUrl: './cnn.component.html',
  styleUrl: './cnn.component.css',
})
export class CnnComponent implements OnInit {
  get outputImage(): Promise<string> {
    return Promise.resolve('https://upload.wikimedia.org/wikipedia/commons/4/4f/Extend_Edge-Handling.png');
  }

  constructor() {}

  ngOnInit(): void {}
}
<div class="container">
  <div class="output-section">
    <img
      *ngIf="outputImage | async as imageSrc"
      [src]="imageSrc"
      class="preview-image"
    />
  </div>
</div>

I am rendering HTML like this hoping to see image, but the page is forever loading even curl is not giving response as anything.

It is also showing same behaviour when i used async method instead and called like this in HTML

<img
  *ngIf="outputImage() | async as imageSrc"
  [src]="imageSrc"
  class="preview-image"
/>
4
  • 1
    Does this answer your question? Angular async pipe hangs on a promise Commented Mar 2, 2024 at 12:27
  • "even curl is not giving response as anything" that's a sign there's a problem with the network, not your angular code. Commented Mar 2, 2024 at 12:52
  • but as soon as I comment that image tag it starts working. Commented Mar 2, 2024 at 12:59
  • I am using SSG in Angular and maybe it is trying to call that method at build time and server is not working. Commented Mar 2, 2024 at 13:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.