Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.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 ngRoute url重定向_Angularjs_Ngroute - Fatal编程技术网

AngularJS ngRoute url重定向

AngularJS ngRoute url重定向,angularjs,ngroute,Angularjs,Ngroute,我有一个使用ngRoute的简单AngularJS应用程序: angular.module('app', [ 'ngRoute' ]) .config(['$routeProvider', function($routeProvider) { $routeProvider .when('/', { templateUrl: 'templates/main.html' }) .when('/profile', { templateUrl: '

我有一个使用ngRoute的简单AngularJS应用程序:

angular.module('app', [
  'ngRoute'
])
.config(['$routeProvider', function($routeProvider) {
  $routeProvider
    .when('/', {
      templateUrl: 'templates/main.html'
    })
    .when('/profile', {
      templateUrl: 'templates/profile.html'
    })
    .otherwise({
      redirectTo: '/'
    });
  }
]);
我正在做oAuth,在oAuth中,我将用户引导到另一个站点进行身份验证,一旦他们通过身份验证,他们将被重定向到我提供的重定向url,并附加了客户端令牌。例如:
http://example.com#client_token=CLIENT_TOKEN

因为我使用的是ngRoute,每当我访问
http://example.com
,url将变为
http://example.com/#/
因此我无法从url获取客户端令牌

我已尝试将其设置为:

  • http://example.com
    但被重定向到
    http://example.com/#/
    。缺少哪个
    client\u-token=client\u-token
  • http://example.com/#/profile
    但被重定向到
    http://example.com/#
  • 但是当我访问
    http://example.com/#/profile#test=abcd
    直接就可以了。
    有人知道怎么回事吗?

    通常您的令牌url是
    http://example.com?client_token=CLIENT_TOKEN
    以避免此类问题。Angular(和大多数其他SPA框架)与浏览器一样,对
    #
    进行了独特的处理。从技术上讲,您尝试使用的URL格式不正确。我使用的是Instagram客户端(隐式)身份验证API,因此没有任何可以更改的内容。如果您的Instagram API出错或键入错误,因为您在评论中发布的链接中的示例URL肯定使用的是
    ,而不是
    #
    。请查看
    客户端(隐式)身份验证API下的最后一个URL
    是的,我刚刚注意到,它不正常。我不确定你是否能用那种回应。您可以尝试在angular中打开
    HTML5模式
    ,但我怀疑您仍然会有问题。通常您的令牌url是
    http://example.com?client_token=CLIENT_TOKEN
    以避免此类问题。Angular(和大多数其他SPA框架)与浏览器一样,对
    #
    进行了独特的处理。从技术上讲,您尝试使用的URL格式不正确。我使用的是Instagram客户端(隐式)身份验证API,因此没有任何可以更改的内容。如果您的Instagram API出错或键入错误,因为您在评论中发布的链接中的示例URL肯定使用的是
    ,而不是
    #
    。请查看
    客户端(隐式)身份验证API下的最后一个URL
    是的,我刚刚注意到,它不正常。我不确定你是否能用那种回应。您可以尝试在angular中打开
    HTML5模式
    ,但我怀疑您仍然会遇到问题。