在url中传递params,而不是params对象:

时间:2021-02-27 21:31:57

I have the below state where i am passing params as like below:

我有下面的状态,我正在传递params,如下所示:

.state("state", {
  url: "/edit/",
  params: {'id': null, 'editMode': true},
  templateUrl: 'views/info.html',
  controller: 'Ctrl'
}); 

How can i pass in the url.

如何传递url。

url: "/edit/?id=''&editMode=true",

2 个解决方案

#1


2  

try this

试试这个

url: "/edit/?id=&editMode=true",

#2


0  

You can try to compose the params before it enters in the function and append it to the url. You can do a for to make the append in the url_param. This way you will pass all the keys in the param variable.

您可以尝试在params进入函数并将其附加到url之前进行组合。可以使用for在url_param中创建追加。这样,您将传递param变量中的所有键。

params = {'id': null, 'editMode': true}
url_params = "?id=" + params['id'] + "&editMode=" + params['editMode']
.state("state", {
  url: "/edit/" + url_params,
  templateUrl: 'views/info.html',
  controller: 'Ctrl'
}); 

#1


2  

try this

试试这个

url: "/edit/?id=&editMode=true",

#2


0  

You can try to compose the params before it enters in the function and append it to the url. You can do a for to make the append in the url_param. This way you will pass all the keys in the param variable.

您可以尝试在params进入函数并将其附加到url之前进行组合。可以使用for在url_param中创建追加。这样,您将传递param变量中的所有键。

params = {'id': null, 'editMode': true}
url_params = "?id=" + params['id'] + "&editMode=" + params['editMode']
.state("state", {
  url: "/edit/" + url_params,
  templateUrl: 'views/info.html',
  controller: 'Ctrl'
});