Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What happen when scope is terminated in angular js?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 754
    Comment on it

    Hello Friends, Some time we get stuck when a scope is terminated and found that two similar destroy events are triggered. Here we want to understand What and why are they two used for in angular js.

    The first one is an Angular jS event, $destroy, and the second one is a jqLite / jQuery event $destroy. The first one can be used by Angular jS scopes where they are accessible, like as in controllers or link functions.

    Lets see the two below happening in a directives function. The Angular jS event:

    scope.$on($destroy, function () {
      // some clean up code here
    });
    
    
    element.on($destroy, function () {
      // jQuery already have this handler.
      // angular.element(document.body).off(someCustomTestEvent);
    });
    

    The jqLite/jQuery event is triggered whenever a node is removed, which can just happen without scope teardown.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: