Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 797
Deblaton Jean-Philippe Avatar asked Jan 26 '15 15:01

Deblaton Jean-Philippe


1 Answers

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>\
like image 170
Deblaton Jean-Philippe Avatar answered Sep 20 '22 23:09

Deblaton Jean-Philippe