Welcome.jsp
<html>
<body ng-app="myApp">
<div class="menu">
<a href="/home"> Home </a>
<a href="/orders" ng-show="$scope.isUserLoggedIn"> View Orders </label>
<a href="/logout" ng-show="$scope.isUserLoggedIn"> Logout </label>
<a href="/login" ng-show="!$scope.isUserLoggedIn"> Login </label>
</div>
<div ng-view></div>
</body>
</html>
Controllers
var myApp = angular.module('myApp', ['ngRoute']);
...
// route for the default home page
.when('/', {
templateUrl : function($node, tattrs) {
return "resources/html/home.html";
},
controller : 'mainController'
})
// route for the orders page
.when('/orders', {
templateUrl : function($node, tattrs) {
return "resources/html/orders.html";
},
controller : 'ordersController'
})
....
myApp.controller('mainController', function($scope, $http) {
....
$scope.isUserLoggedIn = true; //or false
.....
Question:
The $scope.isUserLoggedIn is not affecting the visibility of the Login/Logout buttons. It seems that the scope is not accessible on the main app page (i.e in the menu in the ng-app page).
I need a way to conditionally show/hide the Login/Logout button. Any suggestions?