Here's what I currently have:
<div *ngFor="let career of careers">
<label>{{career.name}}</label>
<input type="checkbox" attr.id="{{career.id}}" (change)="doSomethingWithId($event.target)"
</div>
This is the TypeScript Component code:
doSomethingWithId(target: Element): void {
console.log(target.attributes.id);
}
The error message related to the id attribute is:
Property 'id' does not exist on type 'NamedNodeMap'.
I'm unsure whether using attr.id is the most suitable approach, or if it should be just id, or even data-id. However, my goal is to capture the career.id of the clicked item.