如何阅读与AngularJS网址查询参数? [英] How to read url query parameters with AngularJS?
问题描述
我想获得的使用AngularJS特定的URL参数的值。然后,我想一个特定的值分配给特定的文本框。
I'd like to get the value of specific url parameters using AngularJS. I then want to assign a specific value to a specific textbox.
一个例子URL可能看起来像:
An example URL might look like:
http://example.com/?param1=value1
我见过约$位置,路由和服务的例子。我不想做任何这一点。我只需要参数1的值。任何想法如何可以做?
I've seen examples about $location, routing and services. I don't want to do any of that. I just need the value of param1. Any ideas how that can be done?
下面是几个尝试相应的jsfiddle.net: http://jsfiddle.net/PT5BG/211/
Here's a corresponding jsfiddle.net with several attempts: http://jsfiddle.net/PT5BG/211/
推荐答案
使用$位置是角路
$ location.search()参数1;
应该给它,如果html5mode =真
$location.search().param1;
should give it if html5mode=true
否则,您必须使用纯JavaScript。请确认。
<一href=\"http://stackoverflow.com/questions/523266/how-can-i-get-a-specific-parameter-from-location-search\">How我能得到一个特定参数从location.search?
Otherwise you have to use pure javascript. Check this. How can I get a specific parameter from location.search?
这篇关于如何阅读与AngularJS网址查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!