# Class TemplateRequestProvider

Used to configure the options passed to the $http service when making a template request.

For example, it can be used for specifying the "Accept" header that is sent to the server, when requesting a template.

- Defined in services/template-request.js:12

#####
Index

### Constructors

constructor

### Properties

$get
httpOptions

##
Constructors

### constructor

- new TemplateRequestProvider(): TemplateRequestProvider

- Used to configure the options passed to the $http service when making a template request.

  For example, it can be used for specifying the "Accept" header that is sent to the server, when requesting a template.

  #### Returns TemplateRequestProvider

  - Defined in services/template-request.js:12

##
Properties

### $get

$get: (string | (($exceptionHandler: ErrorHandler, $templateCache: any, $http: any, $q: any, $sce: any) => {
totalPendingRequests: number;
(tpl: any, ignoreRequestError: any): any;
}))[]

The `$templateRequest` service runs security checks then downloads the provided template using `$http` and, upon success, stores the contents inside of `$templateCache`. If the HTTP request fails or the response data of the HTTP request is empty, a `$compile` error will be thrown (the exception can be thwarted by setting the 2nd parameter of the function to true). Note that the contents of `$templateCache` are trusted, so the call to `$sce.getTrustedUrl(tpl)` is omitted when `tpl` is of type string and `$templateCache` has the matching entry.

If you want to pass custom options to the `$http` service, such as setting the Accept header you can configure this via $templateRequestProvider#httpOptions.

`$templateRequest` is used internally by $compile, ngRoute.$route, and directives such as ngInclude to download and cache templates.

3rd party modules should use `$templateRequest` if their services or directives are loading templates.

#### Param: tpl

The HTTP request template URL

#### Param: ignoreRequestError

Whether or not to ignore the exception when the request fails or the template is empty

#### Returns

a promise for the HTTP response data of the given URL.

- Defined in services/template-request.js:56

### httpOptions

httpOptions: ((val: string) => string | TemplateRequestProvider)

The options to be passed to the $http service when making the request. You can use this to override options such as the "Accept" header for template requests. The $templateRequest will set the `cache` and the `transformResponse` properties of the options if not overridden here.

#### Type declaration

- - (val): string | TemplateRequestProvider

  - #### Parameters

    - val: string

      new value for the $http options.

    #### Returns string | TemplateRequestProvider

    Returns the $http options when used as getter and self if used as setter.

- Defined in services/template-request.js:24