HTML源代码如何使用AngularJS
<div ng-app="">
<div ng-controller="test">
<div ng-address-bar browser="html5"></div>
<br><br>
$location.url() = {{$location.url()}}<br>
$location.search() = {{$location.search('keyword')}}<br>
$location.hash() = {{$location.hash()}}<br>
keyword valus is={{loc}} and ={{loc1}}
</div>
</div>
AngularJS源代码
<script>
function test($scope, $location) {
$scope.$location = $location;
$scope.ur = $scope.$location.url('www.html.com/x.html?keyword=test#/x/u');
$scope.loc1 = $scope.$location.search().keyword ;
if($location.url().indexOf('keyword') > -1){
$scope.loc= $location.url().split('=')[1];
$scope.loc = $scope.loc.split("#")[0]
}
}
</script>
这里变量loc
和loc1
得到URL参数都返回测试作为结果的上方网址。这是正确的方法吗?
您可能想查看[$ routeParams](http://docs.angularjs.org/api/ng.$routeParams)。 – 2012-11-08 22:37:40
不清楚你在这里问什么... $ routeParams和$ location#methods文档应该让你开始 – deck 2013-09-06 06:44:09
请在投票时加入一条评论,以便改善问题。谢谢。 – praveenpds 2014-08-13 12:17:33