【发布时间】:2017-06-05 19:21:35
【问题描述】:
我在我的 AngularJS 1.x.x 应用程序中使用 Auth0。
我设置应用程序的方式是使用div ng-if="isAuthenticated" 在我的模板中显示(和隐藏)div。但是,如果用户未通过身份验证,我希望能够阻止我的控制器中的 API 调用。阻止这些调用的正确语法是什么?
我想我正在寻找类似的东西:
if (isAuthenticated) {
ServerRequest.getAllPatients({
}).then(function(resp){
$scope.myTestData = resp
}).catch(function(err){
console.log(err);
});
} else { alert("you are not logged in") }
【问题讨论】: