Skip to main content

Using AngularJS services

To reference AngularJS services, use the following pattern:

var $injector = angular.injector( ['ng'] );
var $http = $injector.get( "$http" );

Example

define( [
  'angular'
], function ( angular ) {

  // Get a reference to the $http service
  var $injector = angular.injector( ['ng'] );
  var $http = $injector.get( "$http" );

  // Your component now using the service
  return {
    componentName: "ccsMyComponent",
    restrict: 'E',
    replace: true,
    link: function ( scope, element, attrs ) {

      // Now you can use $timeout here

    }
  };
} );