Le Quotidien Shaarli

Tous les liens d'un jour sur une page.

03/22/2021

Note: Angular - Utiliser le mécanisme des Forms de base plutôt que celui du Framework

Dans ce cas, l'event à binder n'est pas (submit) mais (ngSubmit) :

<div class="container">
    <div class="logo">Create a new account!</div>
    <div class="register-item">
      <form #myform="ngForm" (ngSubmit)="register(myform)" class="form form-register">

        <div class="form-field">
              <label class="user" for="register-username"><span class="hidden">Name</span></label>
              <input name="name" id="register-username" type="email" class="form-input" placeholder="Name" ngModel required>
        </div>
        <div class="form-field">
          <label class="user" for="register-email"><span class="hidden">Email</span></label>
          <input name="email" id="register-email" type="email" class="form-input" placeholder="Email" ngModel required>
        </div>

        <div class="form-field">
          <label class="lock" for="register-password"><span class="hidden">Password</span></label>
          <input name="password" id="register-password" type="password" class="form-input" placeholder="Password" ngModel required>
        </div>

        <div class="form-field">
          <input type="submit" value="Register">
        </div>
      </form>
    </div>
</div>
Note: Angular - empiler les évènements pour limiter le nombre de requêtes envoyées
this.service.event()
                .pipe(
                    debounceTime(1000),
                    distinctUntilChanged(),
                    tap(() => {
                        this.isLoading = true;
                    })
                )
                .subscribe((data: any) => {
                    this.isLoading = false;
                    if (data != null) {
                    }
                })