AngularJS: Reload ng-include after user authentication (or a better way to solve issue)

前端 未结 2 902
醉话见心
醉话见心 2021-02-05 20:37

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

2条回答
  •  灰色年华
    2021-02-05 20:57

    @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();
       })
    })
    

提交回复
热议问题