angularjs $ http无法识别

时间:2015-10-28 18:51:40

标签: jquery angularjs scriptaculous

我有jquery 1.10,scriptaculous。我在$中修复了与jsp的冲突。现在,我计划在我的代码中实现angular。我认为我在角度和脚本之间存在冲突。我该如何解决?

我在我的代码中使用它

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

我收到错误Uncaught ReferenceError: $http is not defined 如何解决?

1 个答案:

答案 0 :(得分:0)

您需要在控制器中注入$ http依赖项:

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