angularjs - Scope changes after ng-switch -


i have switch changes value of variable called p.

<div ng-switch on="p">    <div ng-switch-when="true">        /*...show nodes , ability add node*/    </div>    <div ng-switch-when="false">        /*for show nothing*/    </div> </div> 

in controller:

$scope.nodes=[{node1},{node2},{node3}];  function add node  $scope.$watch('nodes', function(nodes) {     console.log(nodes);      console.log("================");    },true); 

problem: when print $scope nodes in above new nodes shown. if switch off , on (p=false , p=true) have initial $scope.nodes. why on earth nodes reset on switch? see example: plunker

edit: ng-switch worked no scope change if didn't have directive reinitialized scope when used directive inside it. although haven't understood why dropped ng-switch , used ng-show instead.

it see controller , on level initialized. ngswitch not hide content - remove , add html , initialize controllers , directives each time switch made. nodes initialized there well.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -