WJA
WJA

Reputation: 7004

Redirect url (e.g. website.com/username) in angular

I have an angular website with the user profile (dynamic) on the following url:

http://website.com/#!/market/profile/username

where username is a dynamic variable.

How can I setup my website, such that going to:

http://website.com/username

will redirect to the appropriate url?

Note also that I want to remove the hashbang prefix #

Thanks in advance!

Upvotes: 3

Views: 152

Answers (1)

johnny 5
johnny 5

Reputation: 20987

Here try this:

var sampleApp = angular.module('sampleApp', []);

sampleApp.config(['$routeProvider',
function($routeProvider) {
    $routeProvider.
       when('/:username', {
       templateUrl: 'templates/users/show_user.html',
       controller: 'UsersController'
  });
}]);

This should be a good reference for it here

Upvotes: 1

Related Questions