Skip to content

Commit 6a3ac3f

Browse files
petebacondarwinnetman92
authored andcommitted
docs(filters): clarify filter name restrictions
See angular#10122
1 parent b6b39ee commit 6a3ac3f

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
@@ -243,10 +243,17 @@ function setupModuleLoader(window) {
243243
* @ngdoc method
244244
* @name angular.Module#filter
245245
* @module ng
246-
* @param {string} name Filter name.
246+
* @param {string} name Filter name - this must be a valid angular expression identifier
247247
* @param {Function} filterFactory Factory function for creating new instance of filter.
248248
* @description
249249
* See {@link ng.$filterProvider#register $filterProvider.register()}.
250+
*
251+
* <div class="alert alert-warning">
252+
* **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
253+
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
254+
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
255+
* (`myapp_subsection_filterx`).
256+
* </div>
250257
*/
251258
filter: invokeLater('$filterProvider', 'register'),
252259

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)