Thursday, July 11, 2024

Angular Get Text Box value On Button Click

Angular Get Text Box value On Button Click - The Rich Post

Hello to all, welcome to In this post, I will tell you, how to Get Angular TextBox value On Button Click?

I am doing this in Angular 6.

Here is the working and tested code for Get Angular textBox value on button click:
1. Here is the app.component.html file code:
<div class="jumbotron text-center">
  <h3>Angular Get Text Box value On Button Click:</h3>
<div class="container">
 <div class="form-group">
  <label for="usr">Name:</label>
  <input type="text" #titleInput class="form-control">
  <button type="button" (click) = "showText(titleInput.value)" class="btn btn-primary">Show Button value!</button>


2. Here is the code for app.component.ts file:


import {Component } from '@angular/core';
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
export class AppComponent {
showText(title:string) {
   alert("Fill the name first!!!");

 And you are done, If have any query related to this post, then do ask questions or do comment below.



the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.