Skip to content

Commit 857c4e7

Browse files
committed
docs($templateFactory): adds docs for $templateFactory
1 parent fd16cc7 commit 857c4e7

File tree

1 file changed

+61
-38
lines changed

1 file changed

+61
-38
lines changed

src/templateFactory.js

+61-38
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
/**
2-
* Service. Manages loading of templates.
3-
* @constructor
4-
* @name $templateFactory
2+
* @ngdoc object
3+
* @name ui.router.util.$templateFactory
4+
*
55
* @requires $http
66
* @requires $templateCache
77
* @requires $injector
8+
*
9+
* @description
10+
* Service. Manages loading of templates.
811
*/
912
$TemplateFactory.$inject = ['$http', '$templateCache', '$injector'];
1013
function $TemplateFactory( $http, $templateCache, $injector) {
1114

1215
/**
16+
* @ngdoc function
17+
* @name ui.router.util.$templateFactory#fromConfig
18+
* @methodOf ui.router.util.$templateFactory
19+
*
20+
* @description
1321
* Creates a template from a configuration object.
14-
* @function
15-
* @name $templateFactory#fromConfig
16-
* @methodOf $templateFactory
17-
* @param {Object} config Configuration object for which to load a template. The following
18-
* properties are search in the specified order, and the first one that is defined is
19-
* used to create the template:
20-
* @param {string|Function} config.template html string template or function to load via
21-
* {@link $templateFactory#fromString fromString}.
22-
* @param {string|Function} config.templateUrl url to load or a function returning the url
23-
* to load via {@link $templateFactory#fromUrl fromUrl}.
24-
* @param {Function} config.templateProvider function to invoke via
25-
* {@link $templateFactory#fromProvider fromProvider}.
26-
* @param {Object} params Parameters to pass to the template function.
27-
* @param {Object} [locals] Locals to pass to `invoke` if the template is loaded via a
28-
* `templateProvider`. Defaults to `{ params: params }`.
29-
* @return {string|Promise.<string>} The template html as a string, or a promise for that string,
30-
* or `null` if no template is configured.
22+
*
23+
* @param {object} config Configuration object for which to load a template.
24+
* The following properties are search in the specified order, and the first one
25+
* that is defined is used to create the template:
26+
*
27+
* @param {string|object} config.template html string template or function to
28+
* load via {@link ui.router.util.$templateFactory#fromString fromString}.
29+
* @param {string|object} config.templateUrl url to load or a function returning
30+
* the url to load via {@link ui.router.util.$templateFactory#fromUrl fromUrl}.
31+
* @param {Function} config.templateProvider function to invoke via
32+
* {@link ui.router.util.$templateFactory#fromProvider fromProvider}.
33+
* @param {object} params Parameters to pass to the template function.
34+
* @param {object} locals Locals to pass to `invoke` if the template is loaded
35+
* via a `templateProvider`. Defaults to `{ params: params }`.
36+
*
37+
* @return {string|object} The template html as a string, or a promise for
38+
* that string,or `null` if no template is configured.
3139
*/
3240
this.fromConfig = function (config, params, locals) {
3341
return (
@@ -39,27 +47,37 @@ function $TemplateFactory( $http, $templateCache, $injector) {
3947
};
4048

4149
/**
50+
* @ngdoc function
51+
* @name ui.router.util.$templateFactory#fromString
52+
* @methodOf ui.router.util.$templateFactory
53+
*
54+
* @description
4255
* Creates a template from a string or a function returning a string.
43-
* @function
44-
* @name $templateFactory#fromString
45-
* @methodOf $templateFactory
46-
* @param {string|Function} template html template as a string or function that returns an html
47-
* template as a string.
48-
* @param {Object} params Parameters to pass to the template function.
49-
* @return {string|Promise.<string>} The template html as a string, or a promise for that string.
56+
*
57+
* @param {string|object} template html template as a string or function that
58+
* returns an html template as a string.
59+
* @param {object} params Parameters to pass to the template function.
60+
*
61+
* @return {string|object} The template html as a string, or a promise for that
62+
* string.
5063
*/
5164
this.fromString = function (template, params) {
5265
return isFunction(template) ? template(params) : template;
5366
};
5467

5568
/**
69+
* @ngdoc function
70+
* @name ui.router.util.$templateFactory#fromUrl
71+
* @methodOf ui.router.util.$templateFactory
72+
*
73+
* @description
5674
* Loads a template from the a URL via `$http` and `$templateCache`.
57-
* @function
58-
* @name $templateFactory#fromUrl
59-
* @methodOf $templateFactory
60-
* @param {string|Function} url url of the template to load, or a function that returns a url.
61-
* @param {Object} params Parameters to pass to the url function.
62-
* @return {string|Promise.<string>} The template html as a string, or a promise for that string.
75+
*
76+
* @param {string|Function} url url of the template to load, or a function
77+
* that returns a url.
78+
* @param {Object} params Parameters to pass to the url function.
79+
* @return {string|Promise.<string>} The template html as a string, or a promise
80+
* for that string.
6381
*/
6482
this.fromUrl = function (url, params) {
6583
if (isFunction(url)) url = url(params);
@@ -70,14 +88,19 @@ function $TemplateFactory( $http, $templateCache, $injector) {
7088
};
7189

7290
/**
91+
* @ngdoc function
92+
* @name ui.router.util.$templateFactory#fromUrl
93+
* @methodOf ui.router.util.$templateFactory
94+
*
95+
* @description
7396
* Creates a template by invoking an injectable provider function.
74-
* @function
75-
* @name $templateFactory#fromUrl
76-
* @methodOf $templateFactory
97+
*
7798
* @param {Function} provider Function to invoke via `$injector.invoke`
7899
* @param {Object} params Parameters for the template.
79-
* @param {Object} [locals] Locals to pass to `invoke`. Defaults to `{ params: params }`.
80-
* @return {string|Promise.<string>} The template html as a string, or a promise for that string.
100+
* @param {Object} locals Locals to pass to `invoke`. Defaults to
101+
* `{ params: params }`.
102+
* @return {string|Promise.<string>} The template html as a string, or a promise
103+
* for that string.
81104
*/
82105
this.fromProvider = function (provider, params, locals) {
83106
return $injector.invoke(provider, null, locals || { params: params });

0 commit comments

Comments
 (0)