title: $http GET call with ng-click
body: <p>I'm starting with AngularJS and I need to consume a REST service with it. Why this GET call doesn't work?</p>
  
  <p><strong>controller.js</strong></p>
  
  <pre><code>angular.module("myApp", []);
  
  function GetController($scope) {
  
      $scope.click = function() {
  
          // $http.defaults.useXDomain = true;
  
          var response = $http.get('http://localhost:8080/ticketsales/pruebas');
  
          response.success(function(data, status, headers, config) {
  
              alert("Ok.");
  
          });
  
          response.error(function(data, status, headers, config) {
              alert("Error.");
          });
  
      };
  
  }
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;div ng-controller="GetController"&gt;
  
          &lt;button ng-click="click()"&gt;Click me&lt;/button&gt;
  
  &lt;/div&gt;
  </code></pre>