I am getting query parameters like this from an external service:
url/?error=someError&error_description=someErrorDescription
I've been trying to capture this in my app.js through this routeProvider
$routeProvider.when('/:error', {
templateUrl: 'templates/user.html',
controller: 'MainCtrl as route'
});
but instead of one query parameter I'd need several on the same level. I can do it by splitting the string I am now getting as 'error' but it feels quite dirty. Is there any other Angular solution for several query strings?
答案 0 :(得分:0)
因为您的路线是url/
,所以后面的所有内容都是您的查询。
您无法使用routeProvider处理此问题,请尝试使用$ location provider。
答案 1 :(得分:0)
使用$ location:
angular.module('yourModule').controller('MainCtrl', function($location) {
this.error = $location.search()['error'];
this.errorDescription = $location.search()['error_description'];
});
并在user.html:
{{ route.error }}
{{ route.errorDescription }}