javascript - Angular UI-Router more Optional Parameters in one State -


how can allow optional parameters routes without using query string , using 1 route name? specifying each route 5 times allow combination of parts:

all parts must optional. route must resolve variation.

.state("login", { url: "/login", templateurl: "login.html", params: { a: null, b: null, c: null, d: null } }) .state("logina", { url: "/login/:a", templateurl: "login.html", params: { b: null, c: null, d: null } }) .state("loginab", { url: "/login/:a/:b", templateurl: "login.html", params: { c: null, d: null } }) .state("loginabc", { url: "/login/:a/:b/:c", templateurl: "login.html", params: { d: null } }) .state("loginabcd", { url: "/login/:a/:b/:c/:d", templateurl: "login.html" }) 

there must easier / cleaner / less ugly way.

short answer....

.state('login', {     url: '/login/:a/:b/:c/:d',     templateurl: 'views/login.html',     controller: 'loginctrl',     params: {         a: { squash: true, value: null },         b: { squash: true, value: null },         c: { squash: true, value: null },         d: { squash: true, value: null },     } }) 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -