Event' is not assignable to parameter of type 'MdbCheckboxCh


Topic: Event' is not assignable to parameter of type 'MdbCheckboxChange

Declan Ward pro premium priority asked a year ago

Expected behavior

No error

Actual behavior

Argument of type 'Event' is not assignable to parameter of type 'MdbCheckboxChange'.

Resources (screenshots, code snippets etc.)

<form [formGroup]="chkForm" id="chkIncludeCount" >  
        <div class="row">

          <div class="col-md-12">
            <div class="form-check">
                <input
                mdbCheckbox
                class="form-check-input"
                type="checkbox"
                value=""
                formControlName="chkIncludeCount"
                (change)="onChkChange($event)"
                />
                <label class="form-check-label" for="flexCheckDefault">
                Include document count
                </label>
            </div>

          </div>
        </div>
      </form>

This shows an error

  onChkChange(event: MdbCheckboxChange): void {

Change to any and I get no error

  onChkChange(event: any): void {

The component includes:

import { MdbCheckboxChange } from 'mdb-angular-ui-kit/checkbox';

Am I missing something?


You are listening to a wrong event. Instead of binding to the native HTML (change) event you should bind to our custom event like this:

         <input
            mdbCheckbox
            class="form-check-input"
            type="checkbox"
            value=""
            formControlName="chkIncludeCount"
            (checkboxChange)="onChkChange($event)"
         />

You can always check available outputs in our official docs in API section.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 5.1.0
  • Device: Desktop
  • Browser: All
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: No