AngularJS ngRoute url重定向
我有一个使用ngRoute的简单AngularJS应用程序: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: '
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模式
,但我怀疑您仍然会遇到问题。