# Class TemplateFactory

Service which manages loading of templates from a ViewConfig.

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

#####
Index

### Constructors

constructor

### Properties

$get
$http
$injector
$q
$templateCache
$templateRequest
_useHttp

### Methods

fromComponentProvider
fromConfig
fromProvider
fromString
fromUrl
makeComponentTemplate
useHttpService

##
Constructors

### constructor

- new TemplateFactory(): TemplateFactory

- #### Returns TemplateFactory

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

##
Properties

### $get

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

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

### $http

$http: any

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

### $injector

$injector: InjectorService

- Defined in router/template-factory.js:42

### $q

$q: any

- Defined in router/template-factory.js:41

### $templateCache

$templateCache: any

- Defined in router/template-factory.js:40

### $templateRequest

$templateRequest: any

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

### _useHttp

_useHttp: boolean

- Defined in router/template-factory.js:20
- Defined in router/template-factory.js:52

##
Methods

### fromComponentProvider

- fromComponentProvider(provider, params, context): string

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

  #### Parameters

  - provider: Injectable<T>

    Function to invoke via `locals`

  - params: Function

    a function used to invoke the template provider

  - context: any

  #### Returns string

  The template html as a string: "".

  - Defined in router/template-factory.js:164

### fromConfig

- fromConfig(config, params, context): 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 router/template-factory.js:69

### fromProvider

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

- Creates a template by invoking an injectable provider function.

  #### Parameters

  - provider: Injectable<T>

    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 router/template-factory.js:151

### fromString

- fromString(template, params?): 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 router/template-factory.js:113

### fromUrl

- fromUrl(url, params): 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 router/template-factory.js:127

### makeComponentTemplate

- makeComponentTemplate(ngView, context, component, bindings?): 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 ui-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 router/template-factory.js:184

### useHttpService

- useHttpService(value): void

- Forces the provider to use $http service directly

  #### Parameters

  - value: boolean

  #### Returns void

  - Defined in router/template-factory.js:51