497 questions
2
votes
1
answer
148
views
Change detection not working for child input
I thought @input was supposed to set off the change detector when it is used? When I use the mask input to "disable" this component from a parent component, it just keeps spinning with mat-...
1
vote
1
answer
268
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
2
answers
54
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
80
views
Is zonejs used by plain angular click events?
My question is about angular change detection and zonejs: is zonejs used by the (click) event below?
@Component({
template: `
<button (click)="changeName()">Change name</...
2
votes
1
answer
214
views
If I use Map.get('key1') in angular template, does the change detection mechanism check the map value every cycle?
I know it is not a good practice to call expressions from a template in angular, because angular cannot predict whether the return value of a function has changed, so it needs to execute the function ...
1
vote
0
answers
41
views
angular: subscribe changes on a part of a (complex, hierarchical) component input
I'm creating a component that has a rather complex, nested configuration
export type LayerGroup = {
name: string;
layers: Array<VectorLayerDefinition | TileLayerDefinition | LayerGroup>;
...
1
vote
0
answers
155
views
ViewChild change detection throws ExpressionChangedAfterItHasBeenCheckedError
I have custom Angular Component modal-component that serves as a proxy for MatModalDialog with ngTemplateOutlet as body for mat-dialog-content.
<mat-dialog-content class="modal-dialog-medium&...
2
votes
2
answers
654
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"&...
1
vote
2
answers
130
views
Angular change detection between layouts requires reload
I was required to update a project's UI without breaking any logic(I broke).
In the old UI authentication(login page) and the rest(other resources that you get access to after authentication) were in ...
1
vote
1
answer
180
views
Angular Testing and Change Detection: fixture.detectChanges() only works once in test. Why?
I trying to test a simple component:
HTML:
<ng-container *ngIf="lessThanTen(value) else moreThanTen">
<div
class="circle"
[ngClass]="{'active': isActive}&...
1
vote
2
answers
77
views
Triggering one component after making changes in other component (no parent child) relationship
I want to trigger changes in landing.component.ts once I make changes in cites.component.ts
mediator.service.ts
@Injectable()
export class MediatorService {
private updateValue$: BehaviorSubject<...
1
vote
1
answer
269
views
Best practices for avoiding emitting events inside ngOnChange?
What would be the best practice for avoiding event emitters inside ngOnChanges? Here is a small example:
export class HeroListComponent implements OnChanges {
@Input()
heroNames: string[] = [];
...
0
votes
1
answer
168
views
Angular: ERROR TypeError: this.panZoomAPI.panDelta is not a function
I have made a small ->stackblitz <- to demonstrate my issue.
I have a master component that has pan-zoom within which there's a parent component that holds some content (the children). The ...
1
vote
0
answers
336
views
Angular Custom Control: change event isn't triggered in reactive form
This was working fine for some time until I found out it wasn't. The issue I face is the following.
I have an abstract value accessor class which is being extended by multiple custom form controls. It ...
0
votes
1
answer
809
views
How to update a nested FormGroup passed as input to a child component in Angular?
I have trouble passing the nested FormGroup (the one that is a FormControl of an outer FormGroup) as an input to a child component. More precisely, the changes made to the form group are reflected in ...
0
votes
1
answer
46
views
Angular ChangeDetection Mystery: child event / parent CD trigger logic
My ultimate goal is to prevent triggering CD in ancestor/parent comps when a DOM click event is registered in a child comp. From what I understand, this is not possible, ancestors/parents of the child ...
0
votes
2
answers
178
views
Angular change detection issue in array
I have the following two components in a parent / child relationship:
"Properties" - the parent in this scenario and "listingsList" - the child.
Here's the parent template:
<...
0
votes
1
answer
59
views
how to update childView element height
I want to update each item height in *ngFor elements' based on the tallest item. The idea was to get each height from ViewChild, then emit output to container, and then push it (or via observable ...
0
votes
1
answer
165
views
Angular 15.1 - Infinite Loop on Change Detection when removing babel-polyfill
We had a an old babel-polyfill in our project. Now, when we remove it, Angular DevTools shows an infinite Change Detetction Loop with Source "Window.addEventListener:message".
Anyone has an ...
1
vote
1
answer
50
views
Angular change detection runs unexpectedly, based on the expressions order in the view
I am just playing with Angular change detection cycle and I found something that I can't understand.
We have following component's view:
<!-- ver:1 call() was called 3 times -->
<div>
&...
0
votes
1
answer
1k
views
Why does setTimeout inside runOutsideAngular callback skip change detection for the observable, even if markForCheck is called manually?
I've noticed a strange behavior of change detection in Angular. When Observable updated as in the example, change detection not triggered for some reason.
The key here is setTimeout called inside the ...
0
votes
1
answer
284
views
Why properties value does not change in template onPush strategy?
Component.ts
@Component({
selector: 'app-sample',
templateUrl: './sample.component.html',
styleUrls: ['./sample.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export ...
0
votes
1
answer
441
views
Principe of Angular OnPush + Change detection work
There is 3 components: Parent, Child, ChildChild:
@Component({
template: `<div>{{parentProp}}</div> <child-component></child-component>`,
changeDetection: ...
-1
votes
2
answers
47
views
Why my view is not updated after page is destroyed and i come back with setInterval?
i have two pages
APP COMPONENT HTML
<a routerLink="hello-page">HELLO PAGE</a>
<div></div>
<a routerLink="counter">COUNTER</a>
<router-outlet&...
1
vote
1
answer
696
views
Avoid evaluating input properties on Angular directives after init
I have a very simple Angular attribute directive that looks something like this:
import { Directive, Input, OnInit } from "@angular/core";
@Directive({
selector: "[foo]",
})
...