I am currently developing a small web application using angular. My goal is to implement role-based navigation in the app. However, I am facing an issue where the isAdmin function does not seem to be getting called on page load, resulting in only the foo anchor tag being visible.
HTML
<body ng-controller='AccountController'>
<nav class="navbar navbar-default">
<ul>
<li><a href='google.com'>foo</a></li>
<li ng-if="isAdmin()"><a href='google.com'>bar</a></li>
</ul>
</nav>
</body>
AccountController
var app = angular.module('appControllers', []);
app.controller = angular.controller('AccountController', ['$scope',
function($scope, $http) {
$scope.isAdmin = function() {
return true; //Just as a test to make sure it works
}
}]);
My ultimate goal is for this functionality to hit a web service that will determine the administrator status, but for now, I just want to get it working.
Thank you in advance for all your assistance,
Andres