angular.module, $scope, $http API Reference
AngularJS (1.x) core APIs — module definition with controllers/services/directives, the $scope digest loop, and $http for XHR.
module
angular.module for defining an application module, plus its controller, service, and directive registration.
angular.module(name, requires?) -> moduleGetter/setter for a module. With requires it creates a new module; without requires it retrieves an existing one.
Returns: module
module.controller(name, constructor)Registers a controller constructor on the module; inject dependencies by parameter name or $inject annotation.
Returns: module
module.service(name, constructor)Registers a singleton service instantiated with new; inject dependencies via the constructor.
Returns: module
module.directive(name, factory)Registers a directive with a factory function returning a Directive Definition Object (DDO).
Returns: module
$scope
The $scope object — the glue between controllers and views — and its digest-cycle methods.
$scope.$watch(watchExpression, listener, deep?)Registers a listener callback invoked whenever the watched expression changes during the digest cycle.
Returns: Function (deregistration)
$scope.$apply(expr?)Manually triggers the digest cycle, evaluating expr and propagating changes to watchers. Use when updating scope from non-AngularJS code.
Returns: any (result of expr)
$scope.$on(name, listener)Listens for an event broadcast ($broadcast) or emitted ($emit) on the scope hierarchy.
Returns: Function (deregistration)
$scope.$broadcast(name, args...)Dispatches an event downward to all child scopes (and their children).
Returns: event
$http
The $http service for making XMLHttpRequests. Methods return promises resolved with response data, status, and headers.
$http.get(url, config?) -> PromisePerforms an HTTP GET request. The returned promise resolves to a response object with data, status, headers, config.
Returns: HttpPromise
$http.post(url, data, config?) -> PromisePerforms an HTTP POST request with a request body serialized as JSON by default.
Returns: HttpPromise
$http(config) -> PromiseGeneric request method using a config object with method, url, data, params, headers.
Returns: HttpPromise
promise.then(successCallback, errorCallback?) -> PromiseRegisters callbacks for the response. The success callback receives the full response; the error callback receives the HTTP error.
Returns: Promise