I am really just learning Angular and I am attempting to create an app that limits content access based on authentication. I have the authentication part working (also using the
@Chandermani 's answer is almost close, in fact, you can just add some random params to force refresh, just like this:
app.controller('appController', function($scope){
var getMenu = function(){
var random = Math.random();
return "partials/nav.html?r=" + random;
}
$scope.menuUrl = getMenu();
$scope.$on('userLoggedIn', function(){
$scope.menuUrl = getMenu();
})
})
You can start with raising an event when user login is success on the rootscope using broadcast method
$rootScope.$broadcast('userLoggedIn',{user:user});
On the appController
you can subscribe to the even
$scope.$on("userLoggedIn",function(event,args) {
$scope.menuUrl=null;
$scope.menuUrl="partials/nav.html";
});
this also implies that change your menuUrl to a property in you controller and html binding.
Alos, if you can define multiple server views for logged in and anonymous user, then you can just flip the view on user login.