AngularJS ng-mouseleave 指令
AngularJS 實例
在鼠標指針離開元素時執行表達式:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body ng-app=""><div ng-mouseleave="count = count + 1" ng-init="count=0">鼠標從我這移開!</div><h1>{{count}}</h1><p>該實例在鼠標從 DIV 元素移開時,計算變量 "count" 會自動加 1。</p></body></html>
定義和用法
ng-mouseleave 指令用于告訴 AngularJS 鼠標從 HTML 元素上移開時要執行的操作。
ng-mouseleave 指令不會覆蓋元素的原生 onmouseleave 事件, 事件觸發時,ng-mouseleave 表達式與原生的 onmouseleave事件將都會執行。
語法
<element ng-mouseleave="expression"></element>
所有的 HTML 元素支持該指令。
參數值
值 | 描述 |
---|---|
expression | 鼠標在元素上移開時執行的表達式。 |
以上就是對AngularJS ng-mouseleave指令的基礎資料整理,后續繼續補充相關資料。
新聞熱點
疑難解答