app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'project';
getName(name)
{
alert(name);
}
}
app.component.html
<button (click)="getName('tony')">click me</button>
I am new in angular and I am using version 12.1.4. Now, What happens here if I simply using click event without passing parameters inside getName() and alert("anything") then it works perfectly.
But when I try to pass parameters inside the function and assign value in my click event function. Then it throws an error i.e. Parameter 'name' has implicitly had an 'any' type. Please help me to solve this.