Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5b26521

Browse files
docs(filters): clarify filter name restrictions
See #10122
1 parent abfbfd6 commit 5b26521

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

docs/content/guide/filter.ngdoc

+4-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ means that it should be stateless and idempotent. Angular relies on these proper
9292
the filter only when the inputs to the function change.
9393

9494
<div class="alert alert-warning">
95-
**Note:** filter names must be valid angular expression identifiers, such as `uppercase` or `orderBy`.
96-
Names with special characters, such as hyphens and dots, are not allowed.
95+
**Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
96+
Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
97+
your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
98+
(`myapp_subsection_filterx`).
9799
</div>
98100

99101
The following sample filter reverses a text string. In addition, it conditionally makes the

src/loader.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,17 @@ function setupModuleLoader(window) {
231231
* @ngdoc method
232232
* @name angular.Module#filter
233233
* @module ng
234-
* @param {string} name Filter name.
234+
* @param {string} name Filter name - this must be a valid angular expression identifier
235235
* @param {Function} filterFactory Factory function for creating new instance of filter.
236236
* @description
237237
* See {@link ng.$filterProvider#register $filterProvider.register()}.
238+
*
239+
* <div class="alert alert-warning">
240+
* **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
241+
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
242+
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
243+
* (`myapp_subsection_filterx`).
244+
* </div>
238245
*/
239246
filter: invokeLater('$filterProvider', 'register'),
240247

src/ng/filter.js

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
* Dependency Injected. To achieve this a filter definition consists of a factory function which is
2121
* annotated with dependencies and is responsible for creating a filter function.
2222
*
23+
* <div class="alert alert-warning">
24+
* **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
25+
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
26+
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
27+
* (`myapp_subsection_filterx`).
28+
* </div>
29+
*
2330
* ```js
2431
* // Filter registration
2532
* function MyModule($provide, $filterProvider) {
@@ -101,6 +108,13 @@ function $FilterProvider($provide) {
101108
* @name $filterProvider#register
102109
* @param {string|Object} name Name of the filter function, or an object map of filters where
103110
* the keys are the filter names and the values are the filter factories.
111+
*
112+
* <div class="alert alert-warning">
113+
* **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
114+
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
115+
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
116+
* (`myapp_subsection_filterx`).
117+
* </div>
104118
* @returns {Object} Registered filter instance, or if a map of filters was provided then a map
105119
* of the registered filter instances.
106120
*/

0 commit comments

Comments
 (0)