[英]ng-click not working in firefox
I know this question has been asked multiple times on SO, but I couldn't find any answer 我知道这个问题已被多次询问,但我找不到任何答案
I've got a directive that is responsible of file uploads. 我有一个负责文件上传的指令。
Here is the code of my directive : 这是我的指令的代码:
var directive = {
restrict: 'AE',
scope: {
settings: '='
},
controller: 'fileUploaderCtrl',
replace: true,
template: '<div class="fileTransferContainer uploadContainer" ng-file-drop="onFileSelect($files)" ng-file-drag-over-class="dropBox">\
<fieldset>\
<legend>Uploads in progress</legend>\
<div ng-repeat="file in selectedFiles" class="fileTransfer">\
<span class="up_fileSize"> {{file.size / 1024 | number:2}}KB</span>\
<span>{{file.sizeUploaded()}}</span>\
<div class="progressContainer">\
<div class="up_actions">\
<span>\
<button>\
<a ng-click="remove($index)" class="small_icon white_delete"></a>\
</button>\
</span>\
</div>\
</div>\
</div>\
</fieldset>\
</div>'
}
[...]
And into my controller, I have the following code : 在我的控制器中,我有以下代码:
$scope.remove = function (index) {
debugger;
$scope.selectedFiles.splice(index, 1);
$scope.sendUpdatedModel();
}
What I've tried : 我尝试过的:
As far as my ng-click is inside a ng-repeat, I was wondering if it was not related to scope inheritance. 至于我的ng-click是在ng-repeat中,我想知道它是否与范围继承无关。 I've tried this, with the same results (working in chrome but not in firefox) 我试过这个,结果相同(在chrome中工作但在firefox中没有)
ng-click="$parent.remove($index)"
I've also modified the controller function that way : 我也用这种方式修改了控制器功能:
function remove(index) {
$scope.selectedFiles.splice(index, 1);
$scope.sendUpdatedModel();
}
$scope.remove = remove;
It was also working on chrome, but not in firefox 它也在使用chrome,但不是在firefox中
note that I don't have any error in the console. 请注意我在控制台中没有任何错误。 At this point, I have no idea what I can check/do to understand this bug 此时,我不知道我可以检查/做什么来理解这个bug
It appears that it is not that good to have a <a>
inside a <button>
. 似乎在<button>
有一个<a>
并不是那么好。
I put the answer here, we never know if someone can make errors as stupid as mine ;-) 我把答案放在这里,我们永远不知道是否有人可以像我一样犯错误;-)
<button ng-click="remove($index)" >\
<a class="small_icon white_delete"></a>\
</button>\
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.