我试图将不同长度的值传递给相同的状态:
例如
<li href="#/app/list/value1">
<li href="#/app/list/value1/value2">
在我的州,我有以下
.state('app.list', {
url: "/list/:passedLow/:passedHigh",
views: {
'menuContent': {
templateUrl: "templates/file.html",
controller: 'ValueListCtrl'
}
}
})
我也有
$urlRouterProvider.otherwise('/app/landing');
所以当我点击第二个链接(即传递两个值)时一切正常。但是当我通过单值#34时,否则&#34;接管并将我重定向到着陆页。
那么如何将变量长度值传递为$stateParams
?
答案 0 :(得分:0)
此处的解决方案是使用var deductionLine = function (deductionID, deductionName, amount) {
self = this;
self.deductionID = ko.observable(deductionID);
self.deductionName = ko.observable(deductionName);
self.amount = ko.observable(amount);
self.getreadonlyState = ko.observable('readonly');
self.linkText = ko.computed(function () {
return this.getreadonlyState() == 'readonly' ? "Edit" : "Stop Edit";
}, self);
};
var deductionList = function (deductionID, deductionName, amount) {
self = this;
self.deductionID = ko.observable(deductionID);
self.deductionName = ko.observable(deductionName);
self.amount = ko.observable(amount);
self.getreadonlyState = ko.observable('readonly');
self.linkText = ko.computed(function () {
return this.getreadonlyState() == 'readonly' ? "Edit" : "Stop Edit";
}, self);
};
来定义有关我们参数的更多详细信息:
params: {}
我们可以看到,我们指示UI-Router期望会有param 传递高。默认值为null(可以调整)。我们说,它将在 url - params : { passedHigh : { value : null, squash : true } },
Doc:$stateProvider
有一个完整的州定义
squash: true