javascript - Angular JS prevent controller from running on hidden element -


i have codes

.state('foostate', {     url: '/foo',     templateurl: 'path/to/bar.html',     controller:'parentcontroller' })  // bar.html <div class="sample">     <div ng-show="bazinga" ng-controller="child1controller">         <!-- cool stuff -->     </div>     <div ng-show="!bazinga" ng-controller="child2controller">         <!-- cool stuff -->     </div> </div> 

is normal when first div controller child1controller shown, controller child2controller run? how prevent controller running if hidden via ng-show="false"? need parentcontroller , child1controller controllers running when first div visible. same when 2nd div visible, parentcontroller , child1controller controllers should one's running.

if i'm not mistaken, using ng-if rather ng-show should solve issue. difference being ng-if not render element dom when evaluates false.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -