MACMAN
MACMAN

Reputation: 1971

Adding http module to ionic framework

I am trying to make http call from my ionic app to return some json data. But it shows the error:

[$injector:nomod] Module '$http' is not available!

I think I have to add the module http to Angularjs. Please let me know how to add a new module like http to ionic framework. Thanks.

Upvotes: 0

Views: 934

Answers (1)

Medet Tleukabiluly
Medet Tleukabiluly

Reputation: 11940

$http is not module, it's a service, which is injected like this

angular.module('app').controller('TestController', function($scope, $http){
    //use $http here
    $http.get('https://stackoverflow.com').then(function(successResponse){
       $scope.data = successResponse;
    }, function(errorRepsonse){
       $scope.error = errorRepsonse;
    });
});

Docs

Upvotes: 2

Related Questions