本文介绍了搜索网址参数角JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我有这样的网址:
www.mysite?account=23&token=asdu756sdg65sdf现在,我需要单独使用角JS 访问这些URL的参数。
Now, I need to access those URL parameters individually using Angular JS.
我试过使用 location.search 我的控制器内的:
I've tried using location.search inside my controller:
console.log(location.search);这很好地返回完整的查询字符串:
Which nicely returns the full query string:
?account=23&token=asdu756sdg65sdf但似乎返回一个字符串,而不是一个对象。有一种简单的方法来访问字符串中的个人ID和价值?
But it seems to return a string, not an object. Is there an easy way to access the individual ids and values in the string?
我也试过:
console.log($location.search());这似乎返回一个空的对象。
Which seems to return an empty object.
推荐答案与尝试
var account = ($location.search()).account;但是URL应该像/#!/?帐号= 1
but the url should be like /#!/?account=1
更多推荐
搜索网址参数角JS
发布评论