title: Getting data from JSON url using angularJS
body: <p>I am really new to using AngularJS and Javascript. I need to get the <strong>totalResults</strong> data from a JSON source that looks like this: </p>
  
  <pre><code>{
   "queries": {
    "request": [
     {
      "totalResults": "51"
     }
    ]
   }
  }
  </code></pre>
  
  <p>Once I get the data, I need it to show up in a list using AngularJS. I have tried really hard using .ajax and .getJSON, but I am unable to get either of them to work, given my complete lack of knowledge on using JavaScript. I really appreciate your help! My AngularJS looks like this:</p>
  
  <pre><code>function MyController($scope){
          $scope.url = "https://www.googleapis.com/customsearch/v1?key=[MYKEY]&amp;cx=[MYSECRETKEY]&amp;q=flowers&amp;alt=json&amp;fields=queries(request(totalResults))";
          $scope.newMessage = "";
          $scope.messages = ["Steve Jobs - 515,000,000 results"]; 
  
          $scope.add = function(){
              $scope.messages.push($scope.newMessage);
          };
          }
    }
  </code></pre>
  
  <p>In the HTML part, I have this:</p>
  
  <pre><code>&lt;input type="text" ng-model="newMessage"&gt;
      &lt;input type="submit" ng-click="add()" value="Click to find out!"&gt;
  </code></pre>
  
  <p>When the user clicks the button, I want the url to be called and the <code>$scope.newMessage</code> should be the value in totalResults. Thanks for your help!</p>