Last active
August 6, 2019 06:55
-
-
Save luillyfe/742b468242b7d683670b2e4bae1cfa63 to your computer and use it in GitHub Desktop.
Controlled Components in Angular
This file contains 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
<form class="mx-3"> | |
<div class="form-group"> | |
<label for="email">Email address</label> | |
<input [ngModel]="email" (ngModelChange)="emailHandler($event)" | |
name="email" type="email" class="form-control" id="email" | |
aria-describedby="email" placeholder="Enter email"> | |
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small> | |
</div> | |
</form> |
This file contains 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
... | |
export class AppComponent { | |
email = ""; | |
constructor() {} | |
emailHandler(input) { | |
this.email = input; | |
console.log(this.email); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment