3

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!

WJA
  • 6,676
  • 16
  • 85
  • 152

1 Answers1

1

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

johnny 5
  • 19,893
  • 50
  • 121
  • 195
  • Sounds good, but doesnt that redorect website.com/#/:username instead of website.com/username – WJA Oct 16 '15 at 23:29
  • If you still having an issue, you can use this you just need to switch out of hashbang mode. here is a link to where that can be done http://stackoverflow.com/a/16678065/1938988 please mark your question as complete if this satisfies what you need to do. – johnny 5 Oct 19 '15 at 18:06