Angular updating and clearing factory variables

亡梦爱人 提交于 2019-12-01 23:47:29

If you want it to wipe the value when they change routes (which logout should change routes also, I assume), you can watch the $routeChangeStart event and have it wipe the value whenever it occurs. You put that function in the module.run block:

app.run(function ($rootScope, fact) { 
    $rootScope.$on("$routeChangeStart",function(event, next, current){
        fact.setInformation(null);
    });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!