docs: backport fix to event-binding example for production build (#28423)

Examples are run in production mode and the methods weren't optional.

PR Close #28423
This commit is contained in:
Brandon 2019-02-19 16:00:03 +00:00 committed by Matias Niemelä
parent e8ed37a0e7
commit a5cbfa2aab

View File

@ -11,17 +11,17 @@ export class AppComponent {
currentItem = { name: 'teapot'} ;
clickMessage = '';
onSave(event: KeyboardEvent) {
onSave(event?: KeyboardEvent) {
const evtMsg = event ? ' Event target is ' + (<HTMLElement>event.target).textContent : '';
alert('Saved.' + evtMsg);
if (event) { event.stopPropagation(); }
}
deleteItem(item: Item) {
deleteItem(item?: Item) {
alert(`Delete the ${item}.`);
}
onClickMe(event: KeyboardEvent) {
onClickMe(event?: KeyboardEvent) {
const evtMsg = event ? ' Event target class is ' + (<HTMLElement>event.target).className : '';
alert('Click me.' + evtMsg);
}