0
有沒有可能擁有動態ui.router $stateParams
參數?如果用戶在路線上提供參數,我只想按名稱或序號位置來處理它們。但是,我不想在每一個國家都定義它們。
事情是這樣的......
.state('selector', {
url: '/select/:brandId/:userId/:appId/:appVerId/:featureId/:dialogId/:controlId/:token',
template: null,
controller: 'Selector',
params: {
brandId : { squash: true, value: null },
userId : { squash: true, value: null },
appId : { squash: true, value: null },
appVerId : { squash: true, value: null },
featureId : { squash: true, value: null },
dialogId : { squash: true, value: null },
controlId : { squash: true, value: null },
token : { squash: true, value: null }
}
})
...或...這
.state('selector', {
url: '/select/:a/:b/:c/:d/:e/:f/:g/:h',
template: null,
controller: 'Selector',
params: {
a : { squash: true, value: null },
b : { squash: true, value: null },
c : { squash: true, value: null },
d : { squash: true, value: null },
e : { squash: true, value: null },
f : { squash: true, value: null },
g : { squash: true, value: null },
h : { squash: true, value: null }
}
})
我想通過名稱或序號位置來訪問它們...
var a = $stateParams.a; // or
var b = $stateParams[1];
這將允許以下URL有效:
http://adsf.com/selector
http://adsf.com/selector/////217H3
http://adsf.com/selector/23AD/12D///217H3
誰的定義有效?從來沒有見過像這樣的網址。爲什麼你不能使用查詢參數? – charlietfl
你見過這個答案http://stackoverflow.com/a/30230421/1679310你的問題? –