title: Get the value from json url
body: <p>I am developing a simple application with AngularJS and I want to get the value of the price dynamically I mean to get it from a json data. Is this possible !</p>
  <p>This is my <strong>data.json</strong>:</p>
  <pre><code>{
      &quot;prix&quot;: {
          &quot;prix_diesel&quot;: &quot;8.54&quot;,
          &quot;prix_essence&quot;: &quot;10.30&quot;,
          &quot;prix_aditive&quot;: &quot;0.00&quot;
      }
  }
  </code></pre>
  <p>And this is my <strong>controller</strong> :</p>
  <pre><code>angular.module(&quot;myApp&quot;,['zingchart-angularjs']).controller('MainController', ['$scope', '$http', function($scope, $http) {
  
    $scope.cities =[{
      &quot;name&quot;: &quot;city A&quot;,
          &quot;elements&quot;: [{
            &quot;id&quot;: &quot;c01&quot;,
            &quot;name&quot;: &quot;name1&quot;,
            &quot;price&quot;: &quot;15&quot;,//I want to get this price from the data.json. Get it from the value of prix_diesel attribute 
            &quot;qte&quot;: &quot;10&quot; //I want to get this price from the data.json. Get it from the value of prix_essence attribute 
          }, {
            &quot;id&quot;: &quot;c02&quot;,
            &quot;name&quot;: &quot;name2&quot;,
            &quot;price&quot;: &quot;18&quot;,
            &quot;qte&quot;: &quot;11&quot;
          }, {
            &quot;id&quot;: &quot;c03&quot;,
            &quot;name&quot;: &quot;name3&quot;,
            &quot;price&quot;: &quot;11&quot;,
            &quot;qte&quot;: &quot;14&quot;
          }],
          &quot;subsities&quot;: [{
            &quot;name&quot;: &quot;sub A1&quot;,
            &quot;elements&quot;: [{
              &quot;id&quot;: &quot;sub01&quot;,
              &quot;name&quot;: &quot;nameSub1&quot;,
              &quot;price&quot;: &quot;1&quot;,
              &quot;qte&quot;: &quot;14&quot;
            }, {
              &quot;id&quot;: &quot;sub02&quot;,
              &quot;name&quot;: &quot;nameSub2&quot;,
              &quot;price&quot;: &quot;8&quot;,
              &quot;qte&quot;: &quot;13&quot;
            }, {
              &quot;id&quot;: &quot;sub03&quot;,
              &quot;name&quot;: &quot;nameSub3&quot;,
              &quot;price&quot;: &quot;1&quot;,
              &quot;qte&quot;: &quot;14&quot;
            }]
          }, {
            &quot;name&quot;: &quot;sub A2&quot;,
            &quot;elements&quot;: [{
              &quot;id&quot;: &quot;ssub01&quot;,
              &quot;name&quot;: &quot;nameSsub1&quot;,
              &quot;price&quot;: &quot;1&quot;,
              &quot;qte&quot;: &quot;7&quot;
            }, {
              &quot;id&quot;: &quot;ssub02&quot;,
              &quot;name&quot;: &quot;nameSsub2&quot;,
              &quot;price&quot;: &quot;8&quot;,
              &quot;qte&quot;: &quot;1&quot;
            }, {
              &quot;id&quot;: &quot;ssub03&quot;,
              &quot;name&quot;: &quot;nameSsub3&quot;,
              &quot;price&quot;: &quot;4&quot;,
              &quot;qte&quot;: &quot;19&quot;
            }]
          }, {
            &quot;name&quot;: &quot;sub A3&quot;,
            &quot;elements&quot;: [{
              &quot;id&quot;: &quot;sssub01&quot;,
              &quot;name&quot;: &quot;nameSssub1&quot;,
              &quot;price&quot;: &quot;1&quot;,
              &quot;qte&quot;: &quot;11&quot;
            }, {
              &quot;id&quot;: &quot;sssub02&quot;,
              &quot;name&quot;: &quot;nameSssub2&quot;,
              &quot;price&quot;: &quot;2&quot;,
              &quot;qte&quot;: &quot;15&quot;
            }, {
              &quot;id&quot;: &quot;sssub03&quot;,
              &quot;name&quot;: &quot;nameSssub3&quot;,
              &quot;price&quot;: &quot;1&quot;,
              &quot;qte&quot;: &quot;15&quot;
            }]
          }]
        }, {
          &quot;name&quot;: &quot;city B&quot;,
          &quot;elements&quot;: [{
            &quot;id&quot;: &quot;cc01&quot;,
            &quot;name&quot;: &quot;name11&quot;,
            &quot;price&quot;: &quot;10&quot;,
            &quot;qte&quot;: &quot;11&quot;
          }, {
            &quot;id&quot;: &quot;cc02&quot;,
            &quot;name&quot;: &quot;name22&quot;,
            &quot;price&quot;: &quot;14&quot;,
            &quot;qte&quot;: &quot;19&quot;
          }, {
            &quot;id&quot;: &quot;cc03&quot;,
            &quot;name&quot;: &quot;name33&quot;,
            &quot;price&quot;: &quot;11&quot;,
            &quot;qte&quot;: &quot;18&quot;
          }]
        }, {
          &quot;name&quot;: &quot;city C&quot;,
          &quot;elements&quot;: [{
            &quot;id&quot;: &quot;ccc01&quot;,
            &quot;name&quot;: &quot;name111&quot;,
            &quot;price&quot;: &quot;19&quot;,
            &quot;qte&quot;: &quot;12&quot;
          }, {
            &quot;id&quot;: &quot;ccc02&quot;,
            &quot;name&quot;: &quot;name222&quot;,
            &quot;price&quot;: &quot;18&quot;,
            &quot;qte&quot;: &quot;17&quot;
          }, {
            &quot;id&quot;: &quot;ccc03&quot;,
            &quot;name&quot;: &quot;name333&quot;,
            &quot;price&quot;: &quot;10&quot;,
            &quot;qte&quot;: &quot;5&quot;
          }]
        }]
  
    $scope.extractSubsities = function(itemSelected) {
      if(itemSelected &amp;&amp; itemSelected.elements){
          $scope.data = itemSelected.elements;
      }
  
    }
  
   }]);
  </code></pre>
  <p>I set this up in my plunkr : <a href="http://plnkr.co/edit/NLO0xqyy7L7DHM4onOtQ?p=preview" rel="nofollow noreferrer">plunkr</a></p>
  <p>I search and I found that if I want to get the data from the URL, I'll need an XMLHttpRequest (with Angular, I can use $http.get). do you have any idea please !</p>