Questions tagged [angular2-docheck]

12 questions
58
votes
4 answers

Why do we need `ngDoCheck`

I can't seem to figure out why I need ngDoCheck lifecycle hook other than for simple notification, particularly how writing code inside of it makes a difference as regard to change detection. Most of the examples I've found show useless examples,…
Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
4
votes
2 answers

Angular2 component ngDoCheck is endlessly executed

I have a simple angular2 component that contains only an ag-grid component with some data bind to it. My component implement the DoCheck and the ngDoCheck method is implement in the component. export class AppComponent implements DoCheck { …
Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60
4
votes
2 answers

Angular 2 child component not updating when datasource changes

I have created a table component that generates a table based on a configuration I pass in. I'm aware there are likely better ways of writing a re-usable component, but for now this is what I have. Basically the component takes a config with a…
3
votes
1 answer

deep checking for change similar to $watchCollection in Angular2

I'm using an array of objects which I'm passing from my parent component to child components. When a new item is pushed to the array or the property of one of the existing objects in the array changes it does not trigger the ngOnChanges for the…
3
votes
0 answers

Angular2 unhook lifecycle (ngDoCheck)?

I'm combining 2 responses from 2 api-calls into one. After the 2 responses are done, the combining function should be triggered. I have managed to do this whit a ngDoCheck() as follows: ngDoCheck() { if(this.tasksResponse && this.peopleResponse…
vjawala
  • 67
  • 3
2
votes
1 answer

Angular 2 - How to modify an input B in ngOnChange (triggered by changing input A)

I have a component with an input and a variable: @Input() data: string[]; @Input() val: string = ''; ngOnChanges(changes: SimpleChanges) { for (let propName in changes) { if (propName == 'data') { this.val = 'hello'; …
Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51
2
votes
1 answer

Angular2 KeyValueDiffers is detecting change after init without changing object

I have a form for which I've got a js object as model. I want to detect a change in the object, to inform the user of the need to save. To achieve this, I currently using KeyValueDiffers. It does also detect every change, as wanted. Although I have…
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
1 answer

ngOnchanges and DoCheck in angular

When study the difference between ngOnChanges and DoCheck in Angular, I see something I cant explain and need your help. Basically, I understand that ngOnChanges can't recognize the change of array or object and DoCheck can. I created the stackblitz…
Tony
  • 1,106
  • 1
  • 10
  • 17
0
votes
1 answer

How to reflect/highlight manually entered months on the monthpicker using DoCheck [Angular]

I need your help. I'm literally blocked because of a simple thing. I've created a stackblitz also but first I'll explain the problem. It's quite complicated, please bear with me. I've created a time range selector of my own. A valid range is this:…
Tanzeel
  • 4,174
  • 13
  • 57
  • 110
0
votes
2 answers

ngDoCheck VS using function as attribute value - Performace difference

I have an anchor tag in the web page whose href value depends on a service whose properties are not under control of this component. The service details are populated asynchronously. To get the service details and create the href value, I thought of…
Ravi Sankar Rao
  • 1,050
  • 11
  • 26
0
votes
1 answer

How to watch for changes in an array of objects without causing massive lag?

I feel there are some things that are missing in Angular 2 that Angular 1 had, one of those things being the $watch function. OnChanges and DoCheck are supposed to replace the $watch but I haven't been able to use either to get the desired result.…
Chrillewoodz
  • 27,055
  • 21
  • 92
  • 175