DEV Community

Faisal Ahmed
Faisal Ahmed

Posted on

Ionic loader, without clicking event (loading.dismiss())

In html file,

  <div *ngIf="!isLoading" class="edit-area">
    <div class="container">
      <div class="user">
            <h2>Show This Content</h2>
      </div>
    </div>
  </div>
Enter fullscreen mode Exit fullscreen mode

In ts file

// data store
isLoading = false;

  constructor(
    private loadingCtrl: LoadingController,
  ) { }


  ngOnInit() {
    this.onInitForm();
    // Base Data
    this.getLoggedUserData();
    this.toggleLoading();
  }

  // loading
  async toggleLoading() {
    if (this.isLoading) {
      await this.showLoading();
    }
  }

  async showLoading() {
    const loading = await this.loadingCtrl.create({
      message: 'Loading.....',
      duration: 3000,
    });

    await loading.present();
    loading.dismiss();
    this.isLoading = false;
  }


/***
   * HTTP REQUEST HANDLE
   * getLoggedUserData()
   */
  private getLoggedUserData() {
    this.isLoading = true;
    if (this.isLoading) {
      this.showLoading();
    }
    this.subDataOne = this.userDataService.getLoggedInUserData().subscribe({
      next: (res) => {
        this.user = res.data;
        console.log('this.user', this.user)
        this.setFormValue();
        // this.isLoading = false;
      },
      error: (err) => {
        if (err) {
          console.log(err);
        }
      }
    })
  }


Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more