Git Product home page Git Product logo

Comments (8)

nervgh avatar nervgh commented on June 15, 2024

Hi, @lpsBetty

how can I assert that there are only the needed listeners available?

  1. You can destroy old scope and create new with new uploader instance
  2. You can unbind old listeners
var unsubscribeFn = uploader.bind('afteraddingfile', function() {
    console.info('After adding a file', item);
});

unsubscribeFn(); // unbind a listener

https://github.com/nervgh/angular-file-upload/blob/master/src/scripts/services/%24fileUploader.js#L60

from angular-file-upload.

bettysteger avatar bettysteger commented on June 15, 2024

but how can I destroy old scope? I'm always creating a new uploader instance.

from angular-file-upload.

bettysteger avatar bettysteger commented on June 15, 2024

How can I unbind ALL old listeners? I'm sorry I'm just not getting it ..

from angular-file-upload.

bettysteger avatar bettysteger commented on June 15, 2024

I'm using this in my controller to remove old listeners...

  // remove old listeners
  angular.forEach(uploader.scope.$$listeners, function(value, key){
    if (/(\d+):.*/.test(key)) {
      var timestamp = parseInt(RegExp.$1);
      if(timestamp !== uploader._timestamp) {
        delete uploader.scope.$$listeners[key];
      }
    }
  });

from angular-file-upload.

nervgh avatar nervgh commented on June 15, 2024

but how can I destroy old scope? I'm always creating a new uploader instance.

<div ng-if="case">
    <div ng-controller="TestController"></div>
</div>

How can I unbind ALL old listeners?

second item

from angular-file-upload.

bettysteger avatar bettysteger commented on June 15, 2024

I do exactly that ng-if! but the listeners are already on the $rootScope

from angular-file-upload.

nervgh avatar nervgh commented on June 15, 2024

Create a instance of uploader for $scope of Test Controller instead $rootScope.

https://github.com/nervgh/angular-file-upload#properties
https://github.com/nervgh/angular-file-upload/blob/master/examples/simple/controllers.js#L9

from angular-file-upload.

bettysteger avatar bettysteger commented on June 15, 2024

ahh 👍 thank you very much!

from angular-file-upload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.