route provider - Angularjs same template and controller on different urls -


i have application can run 2 contexts -- 1) global , 2) client

when in global context urls mydomain.com/#login, mydomain.com/#register when in client context urls mydomain.com/#/clientkey/login , mydomain.com/#/clientkey/register. in both contexts want open same template i.e login.html , register.html. 1 way achieve replicate routeprovider.when both cases following

 $routeprovider.when('/:clientkey/_login', {                  templateurl: 'views/login.html',                 controller: 'loginctrl',              })   $routeprovider.when('/_login', {                  templateurl: 'views/login.html',                 controller: 'loginctrl',              }) 

my question is there way in single routeprovider.when, instead of replicating twice small difference. important application because there several such links login, register, editprofile, changepassword etc.

like this?

var routes = {     '/_login' : { templateurl: 'views/login.html', controller:'loginctrl' }     ... }  (var k in routes) {     $routeprovider         .when(k, routes[k])         .when('/:clientid' + k, routes[k]); } 

edit:

you can optional groups ?, following might work.

$routeprovider.when(':clientid?/_login', { ... }); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -