Last active
February 18, 2019 17:44
-
-
Save rajaramtt/34d55af7f3d1d9d26eecdf98ff8a68bf to your computer and use it in GitHub Desktop.
Local References and ViewChild decarator in Angular
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
// <input type="text" class="form-control" trim #giftName /> | |
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; | |
export class UserComponent implements OnInit { | |
userNickName: String = ''; | |
.. | |
onAddGift(giftName: HTMLInputElement) { | |
this.userGiftName = giftName.value; | |
.. | |
.. | |
} | |
export class UserComponent implements OnInit { | |
@ViewChild('nickName') nickName : ElementRef; | |
userNickName: String = ''; | |
.. | |
onAddGift(nickName: HTMLInputElement) { | |
.. | |
this.userNickName = nickName.nativeElement.value; | |
.. | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment