如何在angularJs中双击调用方法?

时间:2016-09-13 18:20:39

标签: javascript angularjs

当用户单击文件时,我有一个填充在模态窗口中的文件列表我已经调用了单击时发生的downloadServerFile方法,如何使用AngularJs双击调用此方法?

main.html中

<td ng-click="downloadServerFile(file.filename)" class="noBorder"><span class="glyphicon glyphicon-file"></span>{{file.filename}}
                    <span class="pull-right text-danger" style="padding-left: 25px" ng-if="file.mostRecent">*</span></td>

3 个答案:

答案 0 :(得分:2)

您可以使用ngDblclick代替ng-click,这样您就可以在dblclick事件上指定自定义行为。

 <td ng-dblclick="downloadServerFile(file.filename)" class="noBorder"><span class="glyphicon glyphicon-file"></span>{{file.filename}}                       <span class="pull-right text-danger" style="padding-left: 25px" ng-if="file.mostRecent">*</span></td>

DEMO APP

答案 1 :(得分:0)

使用ng-dblclick angular指令而不是ng-click。您可以查看文档here

<td ng-dblclick="downloadServerFile(file.filename)" class="noBorder"><span class="glyphicon glyphicon-file"></span>{{file.filename}}<span class="pull-right text-danger" style="padding-left: 25px" ng-if="file.mostRecent">*</span>

答案 2 :(得分:0)

你可以使用ng-dblclick

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

<div ng-controller="SampleController">
    <a ng-dblclick="showAlert()">Double Click Here </a>
</div>

app.controller('SampleController', ['$scope', function ($scope) {
    $scope.showAlert = function () {
        alert("This is an example of ng-dblclick");
    }
}]);