Created
May 1, 2020 17:24
-
-
Save griffgruff/02e29aa4186cc8240b6876d643c80a2b to your computer and use it in GitHub Desktop.
focus
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, AfterViewInit, ElementRef, ViewChild } from '@angular/core'; | |
| @Component({ | |
| selector: 'my-app', | |
| templateUrl: './app.component.html', | |
| styleUrls: [ './app.component.css' ] | |
| }) | |
| export class AppComponent implements AfterViewInit { | |
| name = 'Angular 8 by Example: ElementRef'; | |
| @ViewChild("beer") divView: ElementRef; | |
| //@ViewChild('alert', { read: ElementRef }) alert:ElementRef; | |
| ngAfterViewInit(){ | |
| //console.log(this.divView); | |
| this.divView.nativeElement.focus() | |
| } | |
| } | |
| <hello name="{{ name }}" #test ></hello> | |
| <div #beer >here</div> | |
| <form action="/action_page.php"> | |
| <label for="fname" #just>First name:</label> | |
| <input type="text" id="fname" name="fname" #here><br><br> | |
| <label for="lname">Last name:</label> | |
| <input type="text" id="lname" name="lname"><br><br> | |
| <input type="submit" value="Submit"> | |
| </form> | |
| <div #myDiv> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment