Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 向ionic框架添加http模块_Angularjs_Ionic Framework_Ionic - Fatal编程技术网

Angularjs 向ionic框架添加http模块

Angularjs 向ionic框架添加http模块,angularjs,ionic-framework,ionic,Angularjs,Ionic Framework,Ionic,我正在尝试从我的ionic应用程序进行http调用,以返回一些json数据。但它显示了错误: [$injector:nomod]模块“$http”不可用 我想我必须将模块http添加到Angularjs。请让我知道如何添加一个新的模块,如http的离子框架。谢谢。$http不是模块,而是一项服务,它是这样注入的 angular.module('app').controller('TestController', function($scope, $http){ //use $http h

我正在尝试从我的ionic应用程序进行http调用,以返回一些json数据。但它显示了错误:

[$injector:nomod]模块“$http”不可用


我想我必须将模块http添加到Angularjs。请让我知道如何添加一个新的模块,如http的离子框架。谢谢。

$http
不是模块,而是一项服务,它是这样注入的

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

请显示您的代码?$http.post('/someUrl',{msg:'hello word!'})。然后(函数(响应){//当响应可用时,将异步调用此回调//,如果发生错误,将异步调用函数(响应){//或服务器返回带有错误状态的响应。});angular.module('starter.controllers',[])//从服务中获取数据列表的简单控制器。控制器('PetIndexCtrl',函数($scope,PetService){//“Pets”是返回模拟数据的服务(services.js)$scope.Pets=PetService.all();})//显示点击项的数据的简单控制器。控制器('PetDetailCtrl',function($scope,$stateParams,PetService){/“Pets”是一个返回模拟数据的服务(services.js)$scope.pet=PetService.get($stateParams.petId);});是。@evc是对的。请看他的答案。