Questions tagged [change-detector-ref]

27 questions
1
vote
2 answers

No accurate documentation on angular change detection

Recently I've been learning and experimenting with angular change detection. What I found out is that it's much different than it's described in most articles and documentation, especially regarding onPush components. Example of behaviour that I…
1
vote
0 answers

How can I get untouched status change when click enter in a inputbox

Here is simple input box in a reactive form: Html:
TS: dosomething() { …
1
vote
1 answer

Angular - detectChanges does not invoke ngDoCheck()

I'm running cdr.detectChanges() in some nested child (Child1) that has parent and also another nested child component (Child2). Why if I will run trigger detectChanges method in Child1 component - only ngDoCheck is invoked in Child2 component?…
1
vote
2 answers

How can i cut away change detecion and prevent rerender by a simple class variable in Angular?

I made a very simple demo app to explain what i want exatly to do. @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ] }) export class AppComponent { a=1 b=2 increase(){ …
1
vote
1 answer

Why HTMLElement passed to the component from html via event handler points to the wrong html element?

I have a table and I want to pass HTMLElement of the table cell to the component via click event hadler. At the very begininng I have the pointer to the correct table cell but after I init change detection manually the pointer points to the wrong…
1
vote
2 answers

What is the right way to use changeDetection.markForCheck() in Angular?

I am using markForCheck to detect changes in my angular component (Which has changeDetection: ChangeDetectionStrategy.OnPush) and initially, I put the markForCheck at the start of the function and It was working for me then I realized it will make…
1
vote
2 answers

I got ExpressionChangedAfterItHasBeenCheckedError from child compoenent (timerrenderer), Angular 7

I'm getting the ExpressionChangedAfterItHasBeenCheckedError error from my child component. I tried to add detectChanges() method inside the ngOnchanges but it didn't work. I'm new to angular. I also tried the other questions' solutions but didn't…
1
vote
0 answers

Use html with vanilla javascript outside of angular context

I have an angular application which contains one very simple component for a wysiwyg editor: component.html component.ts editorId: string; constructor() { this.editorId =…
Juliette
  • 966
  • 16
  • 35
1
vote
0 answers

angular html not updating

I'm trying to update component.html according to a value that sent from the service. In service.ts: public loggedIn = new BehaviorSubject(false); generateDoc(): void { this.loggedIn.next(true); //function body here - it takes few…
j.hersh
  • 21
  • 4
1
vote
2 answers

ngOnChanges not triggered though I called ChangeDetectorRef.detectChanges

export class AppComponent implements OnInit, OnChanges { @Input() value: number; constructor( private cdr: ChangeDetectorRef ) {} ngOnInit() { of(1).subscribe(v => { this.value = v; console.log(1); …
critrange
  • 5,652
  • 2
  • 16
  • 47
1
vote
2 answers

Why do I need mark for check ? angular

I am using angular 10, cdktable and I face the following problem. when I execute a search on a table, my pagination do not update unless I click anywhere in the app (that it magically update)... This is a change detection problem, my app is using…
Bobby
  • 4,372
  • 8
  • 47
  • 103
0
votes
2 answers

Why is my ChangeDetectorRef not updating a list in the view?

I have a simple list in the view with hardcoded data in the contoler: errorcount.component.html ... {{errorcounter.date}}
0
votes
1 answer

Angular Change Detection Gives Up After secondary data load on SPA

I have a SPA that ultimately lists out a lot of data, but in batches. I created a component at the bottom of the list, with a 'Visibility' directive so that when it is visible we make a new request to the dataset in a SQL server to get the next…
0
votes
0 answers

refresh angular view changesDetectorRef.markForCheck

I am presenting a difficulty to update the view of a form. in the onInit I define it and the objective is that after with the response of the API update the data of the form and the view, when clicking on the button that activates the toggleDetails…
0
votes
0 answers

Change detection is not working even with ngZone or Array Copy or with setTimeout

I have a function like below, which is invoked from within ngAfterViewInit(). I have a ngFor in the view using the countryUsageTypesArr variable. Now I have tried to put that part of the code inside ngZone.run(), setTimeout(), tried to use spread…
Rakesh Mehta
  • 519
  • 2
  • 9
1
2