398 questions
0
votes
1
answer
56
views
How to debug and identify if the component or a specific part of the component was rerendered?
In Angular, assuming I have this component where automationId is updated every new content while txt is updated less frequent. During those times that txt is NOT updated or the value remains as the ...
2
votes
2
answers
107
views
Does markForCheck trigger a change detection?
I read in several articles telling that markForCheck only marks a components as dirty and does not trigger change detection cycle.
Given the following App Component in Angular 20 Zoneless mode
@...
1
vote
0
answers
81
views
Angular Component Creation Timing Problem
In my production code i have a timing problem regarding component creation. I tried to create a minimal reproduction but in this i don´t get the error.
Maybe somebody has an idea what can cause the ...
1
vote
2
answers
103
views
Angular signals not updating select value
I have a reusable angular component that handles cursor based pagination. However, the select value never changes on the HTML side, yet the change detection works.
Example, select options are 10, 25, ...
0
votes
1
answer
110
views
Issues with ChangeDetection Error after Wrapping with Router Component
After adding a new route to one of the app modules (Angular 15) I had to refactor the main routing component and wrap it into a shell component which is simply this:
import { Component } from '@...
0
votes
2
answers
113
views
"expression has changed after it was checked" error despite having the right setup
I'm facing the error expression has changed after it was checked. I know, that this check runs only in dev mode (runs twice) and that I won't have the error message in prod. But I want to know why I ...
2
votes
2
answers
761
views
Why does my Angular dropdown update selection even when the parent does not store the selected value?
I have an Angular dropdown component (CustomDropdownComponent) that receives a list of options and a selected value from its parent component via @Input(). The parent also listens for selection ...
1
vote
2
answers
104
views
How / whether to replace a getter with a parameter by a computed signal
Is there a comparable signals based approach to something like this:
/** PROPS */
selectedOption = signal<string | null>(null);
getSelectedState(option: string): boolean | undefined {
if (...
1
vote
1
answer
325
views
reload component in Angular 19 with signals
My reload component:
import {ChangeDetectionStrategy, Component, input, output, resource} from '@angular/core';
import {ErrorService} from "../error.service";
@Component({
selector: 'a50-...
1
vote
1
answer
44
views
what triggers change detection when using OnPush and setInterval outside angular zone with markForCheck?
I couldn't really understand what is causing change detection to run in the below code. I understand that markForCheck doesn't do it but something must do it because the view is updated if you play it ...
1
vote
2
answers
323
views
How to optimize Computed Signals: Prevent re-creation for each item after change detection?
I’m using Angular 19 with the new signals API (and OnPush strategy). I have a component that tracks the current URL as a signal, then for each item in an array (e.g., a menu), I create a computed ...
0
votes
1
answer
103
views
How to Prevent Infinite Calls to Angular Getter Methods in Form Validation?
I'm currently facing an issue with infinite calls to a getter method in my Angular component that handles form validation. The getter is used to determine the validity of a form control, but it seems ...
0
votes
1
answer
77
views
UI is not updating the index in Angular child component when trying to change it from the parent component. What am I missing?
I'm trying to update the page index from the parent component in an Angular application using a child component that handles pagination. The child component has an index input property and an event ...
0
votes
1
answer
52
views
What triggers the change detection in an angular application when calling markForChange() method outside of Zonejs?
I am using the following code inside my component's constructor. The component is using the OnPush change detection strategy. As we can see, setTimeout executes outside the Angular zone, meaning ...
1
vote
2
answers
57
views
How to detect view refresh in Angular?
I have a component that displays dynamic, read-only data. For example:
<div>{{getText()}}</div>
I noticed that getText is being invoked over and over by Angular, even if there is ...
1
vote
1
answer
3k
views
Angular signals: how to update an item within an array which is the property of an object?
Perhaps I'm trying to use too-complex signals, let me know if what I am trying to achieve is just not a good use-case for Angular's Signals and I guess I'll try a different approach, but I feel like ...
1
vote
1
answer
105
views
How to update angular mat-table if the drawer is in another component?
Main component has tabs, component A, B etc.
My component_A has preloaded data but I have a button for filter.
I have a button that toggles a drawer from another component (main component).
...
1
vote
2
answers
142
views
Angular not calling the detectChanges() method on button click (change detection)
I have added a breakpoint in the angular source code on the detectChanges() method:
I noticed that when I click on the button from the component below, the breakpoint is not hit.
import { Component, ...
1
vote
0
answers
222
views
NG0100: ExpressionChangedAfterItHasBeenCheckedError: with signals
I randomly have this error ( that I understand the importance of after research ) but I don't understand how to avoid it.
I have an api service with a number Signals initially set to 0 that I update ...
1
vote
2
answers
100
views
Dynamic height calculation incorrect on page load but correct after viewport resize
I have an Angular component that is used with composition, meaning the title of the component changes dynamically based on input. The problem I'm encountering is that when the page loads, the height ...
2
votes
2
answers
3k
views
Angular Calendar Warning: NG0956 - Track by identity caused re-creation of the entire collection
I'm using nz-calendar from ng-zorro-antd in my Angular application. Every time I click on a date in the calendar, I receive the following warning in the console:
NG0956: The configured tracking ...
1
vote
1
answer
60
views
Angular how to swap two components inside dynamic container
I have a dynamic container that shows 2 components at a time using a paginator. I want to be able to swap a component with its previous/next and so far it's working; however, when I try to swap the ...
1
vote
1
answer
49
views
select component dont render values untlil second interaction
The select is not rendering data until the second interaction with him.
<div class="align-items-center">
<label class="form-label">Select Value</label>
...
0
votes
1
answer
43
views
Angular children OnPush Strategy
I have parent component
@Component({
selector: 'parent',
template: '
<div *ngIf="!service.activeTab">DEFAULT</div>
<div *ngIf="service.activeTab">
...
1
vote
1
answer
89
views
Mat-select not updating value of second options list value
In my angular app I have a scenario where I have list of countries and if I select a country it will make an API call and fetched the respective states list. Then if I select state it should display ...
1
vote
1
answer
79
views
Sticky column removed when going to next page of table component
I have a custom table and paginator stand alone components. When I have a table by itself sticky works fine for the column, but when I add a paginator to the table, the sticky is removed whenever I go ...
0
votes
2
answers
704
views
How to force angular not do change detection?
I am trying to have a function which will do sync/async tasks but this should not trigger change detection upon completion. I am triggering this function from the button click in UI.
Template file:
&...
1
vote
1
answer
114
views
What exactly causes the angular component to rerender if not change detection?
Apparently I have a huge missunderstanding about angular's internals.
Consider the following situation:
@Component({
selector: 'banana',
template: ` <h1>We have {{ item.x }} bananas.</h1&...
0
votes
0
answers
55
views
How to handle changes to a field in environment.ts in Angular?
First, due diligence. Here I see how the change detection works. Here is a blog elaborating and explaining the subject. Here I can read about environments. Here I have examples on the change detection ...
1
vote
1
answer
78
views
Change detection in Angular for timers
I was going through the Angular source code trying to find out how change detection is triggered for timers.
I know they are patched, but I can't find a place where the actual change detection is ...
2
votes
2
answers
668
views
Confusing Angular behaviour in *ngFor loop
I'm a bit confused over the behaviour of this loop in Angular:
A simple *ngFor loop over an array of 5 fields
<div *ngFor="let field of this.fields" >
<div class="block"&...
8
votes
3
answers
9k
views
toSignal on observables inside signal
With the recent Angular update (we are using v. 17) we started to use Angular signals in our application. There is one problem we are stumpling accross, that we are not sure how to handle properly.
We ...
1
vote
1
answer
86
views
Angular is not detecting changes
I am having a problem with Angular not detecting when an array has no elements.
Parent:
<child
[trainingData]="trainingData"
>
</child>
Child:
@Input() set ...
0
votes
1
answer
126
views
Why to use @input @output over subject/services?
Generally while passing data from child to parent or parent to child we use @input and @output
what are the benefits @input and @output have over subject or services apart from it's the most organic ...
1
vote
1
answer
80
views
POC on Onpush change detection strategy. How do we show the difference?
I am not able to show the performance difference using default and onPush change detection method. Is there is way to prove this concept? I tried searching online and YouTube however I am not able to ...
0
votes
1
answer
744
views
How to Dynamically Re-render Angular Component on Service Data Change
I'm developing an Angular application with a sidebar component that shows different menu items based on the user's data. The menu should only show an "Empresas" option if the user hasn't ...
3
votes
1
answer
181
views
ngOnChanges does not trigger the second time it's called only
We've built a library at work called ngx-observable-lifecycle.
It's basically hooking into all the native hooks of Angular components (ngOnInit, ngOnChanges, etc) and then gives an object where each ...
1
vote
0
answers
78
views
Using a `@ViewChild` in a template binding throws an `ExpressionChangedAfterItHasBeenCheckedError`
Repro: https://stackblitz.com/edit/angular-rjxytd?file=src%2Fmain.ts
I'm trying to use a dynamic @ViewChild field in an *ngIf binding, but the mere act of mentioning it in a template throws ...
2
votes
1
answer
92
views
mat-menu content view is not updated within onPush component
My component (let's call it cmp) has change detection set to "onPush". Its template contains a <mat-menu> with projected content inside. In that content, some div has a click event ...
2
votes
2
answers
4k
views
PrimeNg tabview tabs selection
In the closable section of prime ng's tabview documentation, I see that when I remove the last tab, it goes to the first tab. My question is: How can I make it go to the tab on the left instead of the ...
1
vote
1
answer
56
views
filter not trigger the change event from text input
I would like to understand, why the change deduction is not works, on keyup while integrate the filter using the input value.
when the key ups, I am getting no of empty string popups to prevent the ...
6
votes
1
answer
6k
views
Angular effect() is not getting triggered on state changes from Observable that are updating the component
I am trying to work with Angular 17 effects using the toSignal() interop class to convert an Observable to a signal. I am registering an effect for that signal in the constructor, and I am expecting ...
3
votes
1
answer
196
views
Angular 17 - ExpressionChangedAfterItHasBeenCheckedError thrown despite calling detectChanges
I'm experiencing a slight issue with Angular and its change detection. I've got a very simple form that allows for additional input containers to be added. Yet, every time I click the add button I get ...
1
vote
1
answer
66
views
Angular iterableDiffers not working with a async input
Parent html
<list-component [items]="birds$ | async"></list-component>
list component ts
export class ListComponent implements DoCheck {
@Input() items: ListItem[];
...
0
votes
1
answer
353
views
Angular testing with OnPush Component and fixture.detectChanges() - how to make the unit test reliable?
In my app I have a Component that simply gets some value async via some service and displays it to the user.
The code of the Component looks like the following:
@Component({
changeDetection: ...
6
votes
1
answer
6k
views
Should I use Signals for any variable I want to display in my Angular 17+ component?
With the addition of Signals and the way they improve Change Detection, I'm wondering if I should start using Signals only (instead of class variables) in order to display data in my component ...
1
vote
2
answers
212
views
Wrapped mat-radio component tests input checked property not working
Hi I am trying to wrap the mat radio button and write unit test but im now blocked on this:
"should uniquely select radios by a name".
I am trying to test the wrapped component with some ...
1
vote
2
answers
3k
views
Change detection with RxJs Angular Signals, how to read new data in observable?
I am attempting to utilise Angular's new Signal feature but struggling with reactivity.
Current Method
From understanding so far, to work with RxJS and Signals correctly the output of this observable ...
1
vote
1
answer
71
views
Angular Property Binding to New Object Instance
In Angular (15), if we have a component property (@Input) that is an object - for instance [config]="{ size: 10, label: 'hello' }" - is the object that is instantiated in HTML being ...
1
vote
1
answer
430
views
How to translate an object with ngx-translate in Angular without force its re render?
In our Angular application, we have an internal library that has several components (like headers...) we use them dynamically in our Angular applications, we passing to them some properties (like ...