0

我正在尝试向 ui-sref 添加参数。如果我尝试这个,它会完美运行

<a ui-sref="services.test({ id: 2 , other_id: 3 })">test</a>

但是如果我尝试这个它不起作用

<a ui-sref="services.test({ id: firstexmple , other_id: secondone })">test</a>
4

1 回答 1

0

如果您尝试将id文本值设置为“firstexample”和other_id“secondone”,则需要像在纯 JavaScript 代码中编写字符串一样编写它们,因此:

<a ui-sref="services.test({ id: 'firstexmple' , other_id: 'secondone' })">test</a>

(请注意,您不能使用双引号(像这样id: "firstexmple"),因为您已经在使用它们来包装整个ui-sref属性的值。

于 2015-06-18T21:53:30.950 回答