@viewChild Angular

import { Component, OnInit,AfterViewInit,  viewChild } from '@angular/core';

@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent implements OnInit, AfterViewInit {

constructor() { }
@ViewChild('addBtn') addBtn:ElementRef;
ngOnInit(): void {
}
ngAfterViewInit() {
// child is set
console.log(this.addBtn.nativeElement)
}

}

<button #addBtn>add</button>

--

--

--

Currently working as UI Frontend Developer I have worked on multiple domains such as E-learning, E-commerce HTML5, CSS3, JavaScript, SASS, Responsive,Angular

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Boilerplate in programming

Implementing interfaces in JavaScript

Learn React Hooks with Theo

A beginner’s guide on how I created a COVID-19 status dashboard [Part-2]

Step by Step — Set up your React + Rails Application with These Easy Steps

JSON — parse() and stringify() in JavaScript

JSON

Leetcode 1441: Build an Array With Stack Operations

Understanding Concurrency in Javascript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ajay Kumar Maheshwari - [Frontend Developer]

Ajay Kumar Maheshwari - [Frontend Developer]

Currently working as UI Frontend Developer I have worked on multiple domains such as E-learning, E-commerce HTML5, CSS3, JavaScript, SASS, Responsive,Angular

More from Medium

Angular Directive

Network visualization Angular

Dependency Injection in Angular

Angular Promise Function