Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Last active January 5, 2018 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinchisholm/3e05e990508da67f015b9fd6c3cdb188 to your computer and use it in GitHub Desktop.
Save kevinchisholm/3e05e990508da67f015b9fd6c3cdb188 to your computer and use it in GitHub Desktop.
How Do I Detect A Text-input Change Event With Angular ?
import {Component} from '@angular/core';
@Component({
selector: 'home',
templateUrl: 'src/home/home.html'
})
export class HomeComponent {
content: string = "";
title: string = "";
changeCount: number = 0;
}
<div>
<h2>Enter some text, and then press the "tab" key.</h2>
<p>(or just click outside of the text box)</p>
<h3>You have made {{changeCount}} changes so far.</h3>
<input
type="text"
(change)="changeCount = changeCount + 1"
placeholder="Enter some text here" />
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment