javascript - How can I access different $scope in angularJS -


i'm trying manipulate ng-switch in navigation using homectrl route template login button. can't figure out how can access different $scope cleaner way without using rootscope or parent hack. please help.

<body ng-app="myapp">      <div class="nav" data-ng-controller="homectrl">         <div ng-switch on="loggedin">             <p ng-switch-when="false">please login</p>             <p ng-switch-when="true">welcome</p>         </div>     </div>      <div class="container" ng-view="">         <!-- partial html -->         <button type="button" ng-click="login()">login</button>         <button type="button" ng-click="logout()">logout</button>     </div>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> <script>  angular.module('myapp', []);  angular.module('myapp').controller('homectrl', ['$scope', function($scope) {    $scope.loggedin = false;    $scope.login = function() {     $scope.loggedin = true;   };   $scope.logout = function() {     $scope.loggedin = false;   }; }]);  </script> </body> 

try 1

<body ng-app="myapp" data-ng-controller="homectrl"> 

instead of placing inside div


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -