Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJs UI router - one state with multiple URLs

I have a request to add in another URL parameter that directs to a state that I already have set up. For efficiency purposes, I'm trying to see if I can add multiple URLs to point to the same state, or should I just use the $UrlRouterProvider.when() method to re-direct to that state in this new case.

Ex. this is what already exists

.state('site.link1',   {     url: '/link1',     templateUrl: '/views/link1.html',     controller: 'link1Ctrl'   }) 

and the request is to add www.site.com/newlink that points to the link1 page. Is there something like this;

.state('site.link1',   {     url: '/link1, /newlink',     ... 
like image 249
kretzm Avatar asked Jan 25 '15 15:01

kretzm


1 Answers

You use params:

https://github.com/angular-ui/ui-router/wiki/URL-Routing

.state('site.link', {     url: '/{link}'     .. } 

so when you use the same state like this

$state.go('site.link', {link: 'link1'}) $state.go('site.link', {link: 'link2'}) 
like image 76
Valter Avatar answered Oct 02 '22 15:10

Valter