angularjs $http is not recognized

215 Views Asked by At

I have jquery 1.10, scriptaculous. I fixed the conflict with $ in my jsp. Now, I'm planning to implement angular in my code. I think i have conflict with $ between angular and scriptaculous. How do i resolve it ?

i'm using this in my code

$http({
                method: 'JSONP',
                url: '' }).then({});

I get the error Uncaught ReferenceError: $http is not defined How to fix it ?

1

There are 1 best solutions below

0
uksz On

You need to inject $http dependency into your controller:

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
    // Simple GET request example:
    $http({
      method: 'GET',
      url: '/someUrl'
    }).then(function successCallback(response) {
        // this callback will be called asynchronously
        // when the response is available
      }, function errorCallback(response) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
      });
    });