1.input keyup:键盘的每一次输入 blur:失去焦点
<input #searchBox id="search-box" (keyup)="search(searchBox.value)" (blur)="update(box.value)"> />
<input type="text" #box (keyup.enter)="addHero(box.value); box.value=''" placeholder="hero name"/> // 输入enter按键时才会响应事件
2.ngSubmit
<form #heroForm (ngSubmit)="onSubmit(heroForm)"> ...</form>
网友评论