In which scenarios would you consider using the ChangeDetectionStrategy.OnPush for a component?
- When the component interacts with external APIs.
- When the component needs to re-render frequently.
- When the component relies on two-way data binding.
- When the component's data is immutable and only changes through input properties.
ChangeDetectionStrategy.OnPush is suitable when a component's data is immutable and only changes through input properties. This strategy optimizes performance by avoiding unnecessary change detection checks. It is not used when two-way data binding is required or when the component re-renders frequently. Interaction with external APIs is typically unrelated to the choice of change detection strategy.
Loading...
Related Quiz
- The process of synchronizing the UI with the underlying form model in Reactive Forms is called ______.
- When creating a custom attribute directive, which decorator is used to define its metadata?
-
When using content projection with
, the projected content's change detection is the responsibility of the ________ component. - To designate a place in your template where the router should display the components for that route, use the ________ directive.
- If you want to prevent navigation away from a component under certain conditions, which Route Guard would you use?