Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angularjs

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!

like image 972
JohnAndrews Avatar asked Feb 20 '26 00:02

JohnAndrews


1 Answers

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

like image 180
johnny 5 Avatar answered Feb 21 '26 14:02

johnny 5



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!