AngularJS ng-mousedown 指令

AngularJS 參考手冊 AngularJS 參考手冊


AngularJS 實(shí)例

在鼠標(biāo)按下時(shí)執(zhí)行表達(dá)式:

<div ng-mousedown="count = count + 1" ng-init="count=0">點(diǎn)我!</div>

<h1>{{count}}</h1>

嘗試一下 ?

定義和用法

ng-mousedown 指令用于告訴 AngularJS 鼠標(biāo)在指定的 HTML 元素上按下時(shí)要執(zhí)行的操作。

ng-mousedown 指令不會(huì)覆蓋元素的原生 onmousedown 事件, 事件觸發(fā)時(shí),ng-mousedown 表達(dá)式與原生的 onmousedown 事件將都會(huì)執(zhí)行。

鼠標(biāo)點(diǎn)擊執(zhí)行的順序:

  1. Mousedown
  2. Mouseup
  3. Click

語法

<element ng-mousedown="expression"></element>

所有的 HTML 元素支持該指令。


參數(shù)值

描述
expression 鼠標(biāo)點(diǎn)擊時(shí)執(zhí)行的表達(dá)式。

AngularJS 參考手冊 AngularJS 參考手冊