UNPKG

4.14 kBTypeScriptView Raw
1import { IAugmentedJQuery } from 'angular';
2import { IInjectable, ResolveContext, RawParams } from '@uirouter/core';
3import { Ng1ViewDeclaration, TemplateFactoryProvider } from './interface';
4/**
5 * Service which manages loading of templates from a ViewConfig.
6 */
7export declare class TemplateFactory implements TemplateFactoryProvider {
8 /** @hidden */ private _useHttp;
9 /** @hidden */ private $templateRequest;
10 /** @hidden */ private $templateCache;
11 /** @hidden */ private $http;
12 /** @hidden */ $get: (string | (($http: any, $templateCache: any, $injector: any) => this))[];
13 /** @hidden */
14 useHttpService(value: boolean): void;
15 /**
16 * Creates a template from a configuration object.
17 *
18 * @param config Configuration object for which to load a template.
19 * The following properties are search in the specified order, and the first one
20 * that is defined is used to create the template:
21 *
22 * @param params Parameters to pass to the template function.
23 * @param context The resolve context associated with the template's view
24 *
25 * @return {string|object} The template html as a string, or a promise for
26 * that string,or `null` if no template is configured.
27 */
28 fromConfig(config: Ng1ViewDeclaration, params: any, context: ResolveContext): Promise<{
29 template?: string;
30 component?: string;
31 }>;
32 /**
33 * Creates a template from a string or a function returning a string.
34 *
35 * @param template html template as a string or function that returns an html template as a string.
36 * @param params Parameters to pass to the template function.
37 *
38 * @return {string|object} The template html as a string, or a promise for that
39 * string.
40 */
41 fromString(template: string | Function, params?: RawParams): any;
42 /**
43 * Loads a template from the a URL via `$http` and `$templateCache`.
44 *
45 * @param {string|Function} url url of the template to load, or a function
46 * that returns a url.
47 * @param {Object} params Parameters to pass to the url function.
48 * @return {string|Promise.<string>} The template html as a string, or a promise
49 * for that string.
50 */
51 fromUrl(url: string | Function, params: any): any;
52 /**
53 * Creates a template by invoking an injectable provider function.
54 *
55 * @param provider Function to invoke via `locals`
56 * @param {Function} injectFn a function used to invoke the template provider
57 * @return {string|Promise.<string>} The template html as a string, or a promise
58 * for that string.
59 */
60 fromProvider(provider: IInjectable, params: any, context: ResolveContext): Promise<any>;
61 /**
62 * Creates a component's template by invoking an injectable provider function.
63 *
64 * @param provider Function to invoke via `locals`
65 * @param {Function} injectFn a function used to invoke the template provider
66 * @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
67 */
68 fromComponentProvider(provider: IInjectable, params: any, context: ResolveContext): Promise<any>;
69 /**
70 * Creates a template from a component's name
71 *
72 * This implements route-to-component.
73 * It works by retrieving the component (directive) metadata from the injector.
74 * It analyses the component's bindings, then constructs a template that instantiates the component.
75 * The template wires input and output bindings to resolves or from the parent component.
76 *
77 * @param uiView {object} The parent ui-view (for binding outputs to callbacks)
78 * @param context The ResolveContext (for binding outputs to callbacks returned from resolves)
79 * @param component {string} Component's name in camel case.
80 * @param bindings An object defining the component's bindings: {foo: '<'}
81 * @return {string} The template as a string: "<component-name input1='::$resolve.foo'></component-name>".
82 */
83 makeComponentTemplate(uiView: IAugmentedJQuery, context: ResolveContext, component: string, bindings?: any): string;
84}
85
\No newline at end of file