Class: $templateFactory

$templateFactory

new $templateFactory()

Service. Manages loading of templates.

Source:
  • templateFactory.js, line 1

Requires

  • module:$http
  • module:$templateCache
  • module:$injector

Methods

fromConfig(config, params, locals) → {string|Promise.<string>}

Creates a template from a configuration object.

Parameters:
Name Type Argument Description
config Object

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:

Properties
Name Type Description
template string | Function

html string template or function to load via fromString.

templateUrl string | Function

url to load or a function returning the url to load via fromUrl.

templateProvider Function

function to invoke via fromProvider.

params Object

Parameters to pass to the template function.

locals Object <optional>

Locals to pass to invoke if the template is loaded via a templateProvider. Defaults to { params: params }.

Source:
  • templateFactory.js, line 12
Returns:

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

Type
string | Promise.<string>

fromString(template, params) → {string|Promise.<string>}

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

Parameters:
Name Type Description
template string | Function

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

params Object

Parameters to pass to the template function.

Source:
  • templateFactory.js, line 41
Returns:

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

Type
string | Promise.<string>

fromUrl(url, params) → {string|Promise.<string>}

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

Parameters:
Name Type Description
url string | Function

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

params Object

Parameters to pass to the url function.

Source:
  • templateFactory.js, line 55
Returns:

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

Type
string | Promise.<string>

fromUrl(provider, params, locals) → {string|Promise.<string>}

Creates a template by invoking an injectable provider function.

Parameters:
Name Type Argument Description
provider Function

Function to invoke via $injector.invoke

params Object

Parameters for the template.

locals Object <optional>

Locals to pass to invoke. Defaults to { params: params }.

Source:
  • templateFactory.js, line 72
Returns:

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

Type
string | Promise.<string>