Monday, November 28, 2022

Angular Show Hide Text on Button Click Simple And easy Example

Angular Show Hide Text on Button Click Simple And easy Example - The Rich Post


Hello to all, welcome to In this post, I am going share very basic example, Angular Show Hide Text on Button Click Simple And easy Example.

I am doing this in Angular 6.

Here is the working example Picture:


Here is the complete working code for Angular Show Hide Text on Button Click.
1. 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 {
//public textShow = true;
 this.textShow = true;
 this.textShow = false;


2. Here is the code for app.component.html file:
<div class="jumbotron text-center">
  <h3>Angular Show Hide Div On Button Click:</h3>
<div class="container">
  <h1 *ngIf="textShow">Button Click Show/Hide!</h1>
  <button type="button" (click) = "showText()" class="btn btn-primary">Show text</button>&nbsp;
  <button type="button" (click) = "hideText()" class="btn btn-danger">Hide Text</button>

 Here you are done and If have any query related to this post, then do ask questions or 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 8, Angular 9, Angular 10, Angular 11, Angular12, Angular 13, Angular 14, Angular 15, 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.