Created
February 7, 2018 22:09
-
-
Save guillefd/8049b318143c37aa386a148c14bd8d21 to your computer and use it in GitHub Desktop.
Angular, get HTML Element by ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, EventEmitter, Output, ElementRef, ViewChild } from '@angular/core'; | |
@Component({ | |
selector: 'form-place', | |
template: `<div #gmap>You got me!</div>`, | |
styleUrls: ['./form-place.component.scss'] | |
}) | |
export class elementComponent implements OnInit { | |
@ViewChild("gmap", {read: ElementRef}) gmap: ElementRef; | |
constructor(private elementRef: ElementRef) {} | |
ngAfterViewInit(): void { | |
console.log(this.gmap.nativeElement); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment