ng-click无法在Firefox中运行

时间:2022-10-22 09:15:43

I know this question has been asked multiple times on SO, but I couldn't find any answer

我知道这个问题在SO上被多次询问过,但我找不到任何答案

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. I've tried this, with the same results (working in chrome but not in firefox)

至于我的ng-click是在ng-repeat中,我想知道它是否与范围继承无关。我试过这个,结果相同(在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

1 个解决方案

#1


6  

It appears that it is not that good to have a <a> inside a <button>.

似乎在

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>\

#1


6  

It appears that it is not that good to have a <a> inside a <button>.

似乎在

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>\