【发布时间】:2015-04-08 22:18:45
【问题描述】:
我这里有一个相对简单的问题,但还没有找到解决方案。我正在使用 Ember 并使用查询参数调用路由。代码如下。
从“ember”导入 Ember;
export default Ember.ObjectController.extend({
queryParams : ['user_id','custom_lis_person_name_given']
user_id : null,
custom_lis_person_name_given : null
});
所以现在假设我正在使用以下 url 调用我的路线,
localhost:4200/index.html#/route1?user_id=123456&custom_lis_person_name_given=hello
现在查询参数的值是
user_id = 123456
custom_lis_person_name_given = hello
现在如果我改变我的网址看起来像
localhost:4200/index.html#/route1?user_id=12345=6&custom_lis_person_name_given=hello
localhost:4200/index.html#/route1?user_id=123456=&custom_lis_person_name_given=hello
现在该值计算为
user_id = 12345 or user_id=123456
custom_lis_person_name_given = hello
所以基本上该值在它看到查询参数值中的 = 符号处结束。有解决方法吗?我需要 user_id="12345=6" 或 "123456="
也许控制器或路由中有一些钩子可以做到这一点。我尝试了 serializeQueryParam 和 deserializeQueryParam 但没有帮助。
提前致谢
【问题讨论】:
-
我有一种解决方法,方法是在创建 URL 之前转义 queryParamter。我刚刚做了 escape('123456=') 并且它起作用了。但是在应用程序中,url 是在后端创建的。如果我能在 UI 端完全修复它会更好
标签: ember.js