1
1
/**
2
- * Service. Manages loading of templates.
3
- * @constructor
4
- * @name $templateFactory
2
+ * @ngdoc object
3
+ * @name ui.router.util.$templateFactory
4
+ *
5
5
* @requires $http
6
6
* @requires $templateCache
7
7
* @requires $injector
8
+ *
9
+ * @description
10
+ * Service. Manages loading of templates.
8
11
*/
9
12
$TemplateFactory . $inject = [ '$http' , '$templateCache' , '$injector' ] ;
10
13
function $TemplateFactory ( $http , $templateCache , $injector ) {
11
14
12
15
/**
16
+ * @ngdoc function
17
+ * @name ui.router.util.$templateFactory#fromConfig
18
+ * @methodOf ui.router.util.$templateFactory
19
+ *
20
+ * @description
13
21
* 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.
31
39
*/
32
40
this . fromConfig = function ( config , params , locals ) {
33
41
return (
@@ -39,27 +47,37 @@ function $TemplateFactory( $http, $templateCache, $injector) {
39
47
} ;
40
48
41
49
/**
50
+ * @ngdoc function
51
+ * @name ui.router.util.$templateFactory#fromString
52
+ * @methodOf ui.router.util.$templateFactory
53
+ *
54
+ * @description
42
55
* 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.
50
63
*/
51
64
this . fromString = function ( template , params ) {
52
65
return isFunction ( template ) ? template ( params ) : template ;
53
66
} ;
54
67
55
68
/**
69
+ * @ngdoc function
70
+ * @name ui.router.util.$templateFactory#fromUrl
71
+ * @methodOf ui.router.util.$templateFactory
72
+ *
73
+ * @description
56
74
* 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.
63
81
*/
64
82
this . fromUrl = function ( url , params ) {
65
83
if ( isFunction ( url ) ) url = url ( params ) ;
@@ -70,14 +88,19 @@ function $TemplateFactory( $http, $templateCache, $injector) {
70
88
} ;
71
89
72
90
/**
91
+ * @ngdoc function
92
+ * @name ui.router.util.$templateFactory#fromUrl
93
+ * @methodOf ui.router.util.$templateFactory
94
+ *
95
+ * @description
73
96
* Creates a template by invoking an injectable provider function.
74
- * @function
75
- * @name $templateFactory#fromUrl
76
- * @methodOf $templateFactory
97
+ *
77
98
* @param {Function } provider Function to invoke via `$injector.invoke`
78
99
* @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.
81
104
*/
82
105
this . fromProvider = function ( provider , params , locals ) {
83
106
return $injector . invoke ( provider , null , locals || { params : params } ) ;
0 commit comments