June 2015
Intermediate to advanced
192 pages
4h 8m
English
Sending JSON with AngularJS is as easy as providing a data attribute in the argument to your $http() method call. AngularJS will even encode the object as JSON on your behalf.
Like before, we'll make an AJAX request. This time, we include a data attribute:
var app = angular.module("aprsapp", []);
app.controller("AprsController", ["$scope", "$http",
function($scope, $http) {
$scope.json = "";
$scope.message = "Loaded...";
$scope.doAjax = function()
{
$scope.debug = "Fetching...";
$scope.json= "";
$scope.message = "";
var request = {
call: "kf6gpe-7"
};
var promise = $http({
url: "/",
method: "POST",
data: request
});
};
}]);We define the JavaScript object request as ...
Read now
Unlock full access