Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
Cannot read properties of undefined (reading 'getAttribute') mat-checkbox

I'm trying to use some Angular Material Components such as mat-checkbox, but when I set a custom attribute, I get

Cannot read properties of undefined (reading 'getAttribute')

The code used is as it goes:

<li *ngFor="let instancia of tipo_maquina.instancias">
    <mat-checkbox 
     (change)="onCheckChange($event, $event.source, $event.checked)"
     [attr.typeid]="instancia.id">
      {{instancia.nombre}}
    </mat-checkbox>
</li>
onCheckChange(event: any, checkbox: MatCheckbox, isChecked: boolean){
    console.log("check event")
    console.log(event.target.getAttribute('typeid'));
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The type of $event should be MatCheckboxChange and it has 2 properties

    /** Change event object emitted by MatCheckbox. */
    export declare class MatCheckboxChange 
    {
        /** The source MatCheckbox of the event. */
        source: MatCheckbox;
        
       /** The new `checked` value of the checkbox. */
        checked: boolean;
    }

So target does not exist on MatCheckboxChange and you would get an error error TS2339: Property target' does not exist on type 'MatCheckboxChange'.

As @MikeOne suggested, just pass instancia.id to the onCheckChange($event, instancia.id) method.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!