ngKeydown/ngKeypress/ngKeyup
該指令在按鍵按下/按鍵按下/按鍵松開時執行指定表達式。
ngKeydown和ngKeypress略有不同,目前的測試是ngKeypress針對系統按鍵是無效的,而ngKeydown可以。
ngKeyup指令在按鍵松開的時候執行。
使用代碼:
<input ng-keydown="count = count + 1" ng-init="count=0">{{count}} <input ng-keypress="count = count + 1" ng-init="count=0">{{count}} <input ng-keyup="count = count + 1" ng-init="count=0">{{count}}
ngMousedown/ngMouseenter/ngMouseleave/ngMousemove/ngMouseover/ngMouseup
該指令在鼠標按下/鼠標進入/鼠標離開/鼠標移動/鼠標在上面/鼠標松開時執行指定表達式。
使用代碼:
<button ng-mousedown="count = count + 1" ng-init="count=0">on mouse down</button>{{count}} <button ng-mouseenter="count = count + 1" ng-init="count=0">when mouse enter</button>{{count}} <button ng-mouseleave="count = count + 1" ng-init="count=0">when mouse leave</button>{{count}} <button ng-mousemove="count = count + 1" ng-init="count=0">when mouse move</button>{{count}} <button ng-mouseover="count = count + 1" ng-init="count=0">when mouse is over</button>{{count}} <button ng-mouseup="count = count + 1" ng-init="count=0">on mouse up</button>{{count}}
本來 不想寫這幾個指令的,畢竟稍簡單了些.... 然后后面想想也許有些時候項目也確實需要用到,還是總結下這幾個指令的用法....