mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
- There was a perceived lag when typing do to the fact that we were listening on the keyup event instead of keydown. The issue with keydown is that we can not read the value of the input field. To solve this we schedule a defer call and perform the model update then. - To prevent calling $eval on root scope too many times as well as to prevent drowning the browser with too many updates we now call the $eval only after 25ms and any additional requests get ignored. The new update service is called $updateView
19 lines
521 B
HTML
19 lines
521 B
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html xmlns:ng="http://angularjs.org">
|
|
<head>
|
|
<script>
|
|
function el(id) {
|
|
return document.getElementById(id);
|
|
}
|
|
function update() {
|
|
el("output").innerHTML = el("input").value;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
Your name: <input id="input" type="text" value="World"
|
|
onkeydown="setTimeout(update,0)"/>
|
|
<hr/>
|
|
Hello <span id="output">{{yourname}}</span>!
|
|
</body>
|
|
</html> |