Reputation: 1153
I'm fairly new to angular and especially the routing portion. I'm using using angular-routing
and am passing over a querystring parameter that has a hash in it. When I do this, $routeParams
only picks up the characters before the hash.
Is there a good way to deal with this?
Routes where :battle_tag
is name#number, like pizza#7777
.
var diabloApp = angular.module('diabloApp', ['ngRoute']);
diabloApp.config(function ($routeProvider, $locationProvider){
$routeProvider
.when('/heroes/:id/:battle_tag', {
controller: 'heroesController',
templateUrl: '../templates/Heroes.html'
})
.otherwise({
controller: 'homeController',
templateUrl: '../templates/Index.html'
})
$locationProvider.html5Mode(true);
});
I've been looking for good ways to encode this but it's really not an encoding issue. I realize separate it on from the hrefs but it really would be a pain and doesn't seem a great way to do it.
Any input is appreciated. Thanks in advance!
Upvotes: 1
Views: 483
Reputation: 30108
You can separate the :battle_tag
parameter into two parts instead:
/heroes/:id/:battle_tag_name/:battle_tag_number
This way, AngularJS' $routeProvider
detects the route as it is.
Upvotes: 1