Hi Guys, am creating login form in ionic 2 but i have some error i don’t know how to solve. Please help me how to use ionic 2 checkbox and ngModel value binding and ionchange event.
** My Ion View **
<form [formGroup]=“loginfrm” (ngSubmit)=“btnLoginClick()” novalidate>
<ion-label floating> Username </ion-label>
<ion-input name="username" type="text" [(ngModel)]="username" formControlName="username"></ion-input>
</ion-item>
<ion-item>
<ion-label>Remember Me</ion-label>
<ion-checkbox color="primary" [(ngModel)]="rmchecked" (ionChange)="LoginRemCheck(rmchecked)" formControlName="rmchecked"></ion-checkbox>
</ion-item>
<button ion-button full block type="submit" [disabled]="!loginfrm.valid"> Login </button>
</ion-list>
** My controller **
this.loginfrm = this.formBuilder.group({
“username”: ["", Validators.required],
“password”: ["", Validators.required]
});
LoginRemCheck(isChecked) {
isChecked = true;
}
** ERROR **
**
Error: Cannot find control with name: ‘rmchecked’
** at _throwError (\F:\IonicExamples\MyApp2\node_modules@angular\forms\src\directives\shared.js:102:11)**
** at setUpControl (\F:\IonicExamples\MyApp2\node_modules@angular\forms\src\directives\shared.js:40:9)**
** at FormGroupDirective.addControl (\F:\IonicExamples\MyApp2\node_modules@angular\forms\src\directives\reactive_directives\form_group_directive.js:109:93)**
** at FormControlName._setUpControl (\F:\IonicExamples\MyApp2\node_modules@angular\forms\src\directives\reactive_directives\form_control_name.js:164:44)**
** at FormControlName.ngOnChanges (\F:\IonicExamples\MyApp2\node_modules@angular\forms\src\directives\reactive_directives\form_control_name.js:110:18)**
** at Wrapper_FormControlName.detectChangesInternal (/ReactiveFormsModule/FormControlName/wrapper.ngfactory.js:44:18)**
** at _View_LoginPage0.detectChangesInternal (/AppModule/LoginPage/component.ngfactory.js:553:30)**
** at _View_LoginPage0.AppView.detectChanges (\F:\IonicExamples\MyApp2\node_modules@angular\core\src\linker\view.js:243:14)**
** at _View_LoginPage0.DebugAppView.detectChanges (\F:\IonicExamples\MyApp2\node_modules@angular\core\src\linker\view.js:348:44)**
** at _View_LoginPage_Host0.AppView.detectViewChildrenChanges (\F:\IonicExamples\MyApp2\node_modules@angular\core\src\linker\view.js:269:19)o @ polyfills.js:3r @ polyfills.js:3i @ polyfills.js:3**
polyfills.js:3 Error: Uncaught (in promise): Error: Error in ./LoginPage class LoginPage - inline template:31:38 caused by: Cannot find control with name: ‘rmchecked’
Thanks guys.