title: How to get the url parameters using AngularJS
body: <p>HTML source code </p>
  
  <pre><code>&lt;div ng-app=""&gt;
      &lt;div ng-controller="test"&gt;
        &lt;div ng-address-bar browser="html5"&gt;&lt;/div&gt;
        &lt;br&gt;&lt;br&gt;
        $location.url() = {{$location.url()}}&lt;br&gt;
        $location.search() = {{$location.search('keyword')}}&lt;br&gt;
        $location.hash() = {{$location.hash()}}&lt;br&gt;     
        keyword valus is={{loc}} and ={{loc1}}
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>AngularJS source code</p>
  
  <pre><code>&lt;script&gt;
  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') &gt; -1){    
          $scope.loc= $location.url().split('=')[1];
          $scope.loc = $scope.loc.split("#")[0]        
      }
    }
   &lt;/script&gt;
  </code></pre>
  
  <p>Here the variables <code>loc</code> and <code>loc1</code> both return <em>test</em> as the result for the above URL. Is this the correct way?</p>