Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 专家建议:在$routeProvider/resolve或$routeChangeStart中进行角度身份验证?_Angularjs_Authentication - Fatal编程技术网

Angularjs 专家建议:在$routeProvider/resolve或$routeChangeStart中进行角度身份验证?

Angularjs 专家建议:在$routeProvider/resolve或$routeChangeStart中进行角度身份验证?,angularjs,authentication,Angularjs,Authentication,在深入研究Angular中进行身份验证/授权的选项时,我发现通常有两种可能性: 第一个也是可能主要使用的选项是在angular.config/$routeProvider中创建一个resolve函数。。。功能。 例如 第二种可能是检查“$routeChangeStart”上angular.run/$rootScope.$的用户权限。。。。 例如 我找到了很多这两个选项的例子,但没有解释为什么我应该使用第一个或第二个选项。我的想法是,可以在调用$routeChangeStart之前取消路由请求。无

在深入研究Angular中进行身份验证/授权的选项时,我发现通常有两种可能性:

第一个也是可能主要使用的选项是在angular.config/$routeProvider中创建一个resolve函数。。。功能。 例如

第二种可能是检查“$routeChangeStart”上angular.run/$rootScope.$的用户权限。。。。 例如

我找到了很多这两个选项的例子,但没有解释为什么我应该使用第一个或第二个选项。我的想法是,可以在调用$routeChangeStart之前取消路由请求。无论如何,使用resolve,我必须对每个路由执行检查,但UI路由器除外。$routeChangeStart方法在我看来更像是一种中间件方法,因此是更好的选择

有人能告诉我这个或那个的其他/更多原因吗