javascript - Directive scope variable -


i using directive 3 consecutive time in html page, scope variable passing different @ every time taking scope variable third directive ?, example first time,

<my-dir is-active=true></my-dir>  

sec time,

<my-dir is-active="true"></my-dir> 

third time,

<my-dir is-active="true" is-action="true"><my-dir> 

js:

angular .module('app') .directive("mydir", function(){  scope:{   isactive:'@',   isaction:'@'  }, controller:[function('$scope'){   $scope.isaction ? doaction() : doactive();   function doaction()  {     console.log('in action');   }    function doactive()   {     console.log('in active');   } }] }) 

here @ every time getting "in action" log 3 time ? should 1 time not passing "isaction" scope directive first 2 time ?

i pretty sure issues syntax errors. if correct seems work correctly.

plunker

.directive("mydir", function(){   return {    scope:{     isactive:'@',     isaction:'@'    },    controller:function($scope){       $scope.isaction ? doaction() : doactive();        function doaction()       {         console.log('in action');       }        function doactive()       {         console.log('in active');       }     }   } }) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -