flosrn
January 13, 2018, 1:28pm
1
Hello, I want enable register button only when the toglle condition of use is checked like this :
register.html :
<ion-item class="CGU" no-lines>
<ion-label class="CGU">I accept the conditions of use</ion-label>
<ion-toggle color="secondary" [checked]="isToggled" (ionChange)="notify()"></ion-toggle>
</ion-item>
<button ion-button class="login" color="bleu" type="submit" (click)="register()" [disabled]="isToggled != true">Register</button>
register.ts :
public isToggled: boolean = false;
constructor(...) {...}
notify() {
this.isToggled = !this.isToggled;
}
But it not working…
Nobody knows how to do it please?
<ion-item class="CGU" no-lines>
<ion-label class="CGU">I accept the conditions of use</ion-label>
<ion-toggle color="secondary" [(ngModel)]="agreements"></ion-toggle>
</ion-item>
<button ion-button class="login" color="bleu" type="submit" (click)="register()" [disabled]="!agreements" Register</button>
flosrn
January 13, 2018, 2:11pm
3
user5555:
!agreements
Not working : Uncaught (in promise): Error: \n ngModel cannot be used to register form controls with a parent formGroup directive. Try using\n formGroup’s partner directive "formControlName" instead.
I think I can’t use Ngmodel because I already use that in the rest of my code for something else…
I think I must use [checked] and (ionChange)
flosrn
January 13, 2018, 2:22pm
4
ok it work like that :
<ion-item class="CGU" no-lines>
<ion-label class="CGU">I accept the conditions of use</ion-label>
<ion-toggle color="secondary" [checked]="isToggled" (ionChange)="notify()"></ion-toggle>
</ion-item>
<button ion-button class="login" color="bleu" type="submit" (click)="register()" [disabled]="!isToggled">Register</button>
quite simply…