$http GET call with ng-click

Problem

I'm starting with AngularJS and I need to consume a REST service with it. Why this GET call doesn't work?

controller.js

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.");
        });

    };

}

index.html

<div ng-controller="GetController">

        <button ng-click="click()">Click me</button>

</div>
Problem courtesy of: Héctor

Solution

You aren't passing $http to the function:

function GetController($scope)

to:

function GetController($scope, $http)

http://jsfiddle.net/rd13/mM2g7/2/

Seriously though, you need to look at your console, if you had a console open you would have seen something like: "ReferenceError: $http is not defined".

Solution courtesy of: StuR

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.