@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>

--

--

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