How can I pass input values to a function in order to trigger an alert? Check out the HTML code below:
<div class="container p-5 ">
<input #titleInput *ngIf="isClicked" type="text" class="col-4"><br>
<button (click)="OnClick()" class="btn btn-primary col-2 ">
Show
</button>
<button (click)="Send(titleInput.value)" class="btn btn-success col-2 m-3">
Send
</button>
</div>
Additionally, here is the corresponding component.ts file:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
Send(data: any) {
alert(data);
}
OnClick() {
this.isClicked = true;
}
title = 'demoproject1';
isClicked = false;
}
I need assistance retrieving the value entered into the input field and passing it to the function within my component.