# Class TemplateFactoryProvider

Service which manages loading of templates from a ViewConfig.

- Defined in src/router/template-factory.js:17

##### Index

### Constructors

constructor

### Properties

_useHttp
$get
$http
$injector
$templateCache
$templateRequest

### Methods

fromComponentProvider
fromConfig
fromProvider
fromString
fromUrl
makeComponentTemplate
useHttpService

## Constructors

### constructor

- new TemplateFactoryProvider(): TemplateFactoryProvider

  #### Returns TemplateFactoryProvider

  - Defined in src/router/template-factory.js:18

## Properties

### _useHttp

_useHttp: boolean

- Defined in src/router/template-factory.js:20
- Defined in src/router/template-factory.js:49

### $get

$get: (
| string
| (
(
$http: any,
$templateCache: TemplateCache,
$templateRequest: any,
$injector: InjectorService,
) => TemplateFactoryProvider
)
)[] = ...

#### Type declaration

- string
- (
  $http: any,
  $templateCache: TemplateCache,
  $templateRequest: any,
  $injector: InjectorService,
  ) => TemplateFactoryProvider
  - - (
      $http: any,
      $templateCache: TemplateCache,
      $templateRequest: any,
      $injector: InjectorService,
      ): TemplateFactoryProvider

    - #### Parameters

      - $http: any
      - $templateCache: TemplateCache
      - $templateRequest: any
      - $injector: InjectorService

      #### Returns TemplateFactoryProvider

- Defined in src/router/template-factory.js:23

### $http

$http: any

- Defined in src/router/template-factory.js:37

### $injector

$injector: InjectorService

- Defined in src/router/template-factory.js:39

### $templateCache

$templateCache: TemplateCache

- Defined in src/router/template-factory.js:38

### $templateRequest

$templateRequest: any

- Defined in src/router/template-factory.js:36

## Methods

### fromComponentProvider

- fromComponentProvider(provider: Injectable, context: any): Promise<any>

  Creates a component's template by invoking an injectable provider function.

  #### Parameters

  - provider: Injectable

    Function to invoke via `locals`

  - context: any

  #### Returns Promise<any>

  The template html as a string: "".

  - Defined in src/router/template-factory.js:160

### fromConfig

- fromConfig(config: any, params: any, context: ResolveContext): any

  Creates a template from a configuration object.

  #### Parameters

  - config: any

    Configuration object for which to load a template. The following properties are search in the specified order, and the first one that is defined is used to create the template:

  - params: any

    Parameters to pass to the template function.

  - context: ResolveContext

    The resolve context associated with the template's view

  #### Returns any

  The template html as a string, or a promise for that string,or `null` if no template is configured.

  - Defined in src/router/template-factory.js:66

### fromProvider

- fromProvider(
  provider: Injectable,
  params: Function,
  context: ResolveContext,
  ): string | Promise<string>

  Creates a template by invoking an injectable provider function.

  #### Parameters

  - provider: Injectable

    Function to invoke via `locals`

  - params: Function

    a function used to invoke the template provider

  - context: ResolveContext

  #### Returns string | Promise<string>

  The template html as a string, or a promise for that string.

  - Defined in src/router/template-factory.js:148

### fromString

- fromString(template: string | Function, params?: any): any

  Creates a template from a string or a function returning a string.

  #### Parameters

  - template: string | Function

    html template as a string or function that returns an html template as a string.

  - `Optional` params: any

    Parameters to pass to the template function.

  #### Returns any

  The template html as a string, or a promise for that string.

  - Defined in src/router/template-factory.js:110

### fromUrl

- fromUrl(url: string | Function, params: any): string | Promise<string>

  Loads a template from the a URL via `$http` and `$templateCache`.

  #### Parameters

  - url: string | Function

    url of the template to load, or a function that returns a url.

  - params: any

    Parameters to pass to the url function.

  #### Returns string | Promise<string>

  The template html as a string, or a promise for that string.

  - Defined in src/router/template-factory.js:124

### makeComponentTemplate

- makeComponentTemplate(
  ngView: any,
  context: ResolveContext,
  component: string,
  bindings?: any,
  ): string

  Creates a template from a component's name

  This implements route-to-component. It works by retrieving the component (directive) metadata from the injector. It analyses the component's bindings, then constructs a template that instantiates the component. The template wires input and output bindings to resolves or from the parent component.

  #### Parameters

  - ngView: any

    {object} The parent ng-view (for binding outputs to callbacks)

  - context: ResolveContext

    The ResolveContext (for binding outputs to callbacks returned from resolves)

  - component: string

    {string} Component's name in camel case.

  - `Optional` bindings: any

    An object defining the component's bindings: {foo: '<'}

  #### Returns string

  The template as a string: "".

  - Defined in src/router/template-factory.js:180

### useHttpService

- useHttpService(value: boolean): void

  Forces the provider to use $http service directly

  #### Parameters

  - value: boolean

  #### Returns void

  - Defined in src/router/template-factory.js:48