2015-10-28 135 views
-1

我有jquery 1.10,scriptaculous。我在我的jsp中解決了與$的衝突。現在,我打算在我的代碼中實現角度。我認爲我在角度和scriptaculous之間與$有衝突。我如何解決它?

我在我的代碼

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

使用此我得到的錯誤Uncaught ReferenceError: $http is not defined 如何解決呢?

+0

你有沒有注射'$ http'在控制器的依賴? –

+0

你需要提供更多的細節,比如你的控制器/服務定義代碼是什麼樣的,在哪裏注入''http'' –

+0

一個plunker或者jsfiddle會有很大的幫助 –

回答

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