So I have a Component.html that includes an input as follows:
<input type="text" (change) = "setNewUserName($event.target.value)"/>
the component.ts is:
import { Component } from "@angular/core";
@Component({
selector : 'app-users-list',
templateUrl : './usersList.component.html'
})
export class UsersListComponent
{
setNewUserName (userName : string): void {
console.log('setNewUserName', userName)
}
}
and finally the module.ts is:
@NgModule ({
declarations: [UsersListComponent],
imports : [CommonModule],
exports: [UsersListComponent]
})
export class UsersListModule {}
When running the server, the following error pops up:
error TS2531: Object is possibly 'null'.
1 <input type="text" (change) = "setNewUserName($event.target.value)"/>
~~~~~