You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/components/minimize-logic-in-templates.md
+21-17Lines changed: 21 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,38 +8,42 @@ When we put too much logic in our templates, we are making our applications more
8
8
9
9
In addition, too much logic inside the template makes them less readable. We cannot take a quick glance at the template and quickly understand what's going on.
10
10
11
-
# Solution
12
-
13
-
Try to avoid putting too much logic in your templates.
14
-
15
-
For example here, we have have an `*ngIf` that has too much logic.
11
+
For example here, we have have an `@if` that has too much logic.
Be careful when the `ChangeDetectionStrategy` is set to `Default`, as it'd cause the functions bound in the template to be called each time the `Change Detection Cycle` runs. You can optimize this by turning on the `OnPush` change detection strategy and leverage the `async` pipe in combination with `Observables` that return the desired value.
48
+
Be careful when the `ChangeDetectionStrategy` is set to `Default`, as it'd cause the functions bound in the template to be called each time the `Change Detection Cycle` runs.
49
+
You can optimize this by turning on the `OnPush` change detection strategy and leverage the `async` pipe in combination with `Observables` that return the desired value.
0 commit comments