This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ Filters may have arguments. The syntax for this is
31
31
E.g. the markup `{{ 1234 | number:2 }}` formats the number 1234 with 2 decimal points using the
32
32
{@link ng.filter:number `number`} filter. The resulting value is `1,234.00`.
33
33
34
+ ### When filters are executed
35
+
36
+ In templates, filters are only executed when their inputs have changed. This is more performant than executing
37
+ a filter on each {@link ng.$rootScope.Scope#$digest `$digest`} as is the case with {@link guide/expression expressions}.
38
+ However, this is only true for filters that take [primitive values](https://developer.mozilla.org/docs/Glossary/Primitive)
39
+ as inputs. Filters that receive [Objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Objects)
40
+ as input are executed on each `$digest`, as it would be too costly to track if they have changed.
41
+
42
+ This means custom filters should only rely on their inputs and not on external state (e.g. other Angular services).
43
+ See {@link guide/filter#creating-custom-filters Creating custom filters} below for more information.
34
44
35
45
## Using filters in controllers, services, and directives
36
46
@@ -141,7 +151,7 @@ text upper-case.
141
151
</example>
142
152
143
153
144
- ## Stateful filters
154
+ ### Stateful filters
145
155
146
156
It is strongly discouraged to write filters that are stateful, because the execution of those can't
147
157
be optimized by Angular, which often leads to performance issues. Many stateful filters can be
You can’t perform that action at this time.
0 commit comments