最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - Primeng datepicker repeatedly causes change detection when i use ngModel - Stack Overflow

programmeradmin2浏览0评论

I have a datepicker which repeatedly triggers change detection whenever ngModel is being used (not even ngModelChange, just the input). This happens on ChangeDetectionStrategy.OnPush or Default.

This component is in a secondary project if that changes anything.

  • Angular version: 19
  • Primeng version: 19

Edit to clarify: the output isn't used. Here is what it looks like.

<p-datepicker [ngModel]="date" />

I have a datepicker which repeatedly triggers change detection whenever ngModel is being used (not even ngModelChange, just the input). This happens on ChangeDetectionStrategy.OnPush or Default.

This component is in a secondary project if that changes anything.

  • Angular version: 19
  • Primeng version: 19

Edit to clarify: the output isn't used. Here is what it looks like.

<p-datepicker [ngModel]="date" />

Share Improve this question edited Mar 17 at 19:47 Joseph Coulter asked Mar 17 at 19:23 Joseph CoulterJoseph Coulter 995 bronze badges 3
  • What do you mean by "datepicker which repeatedly triggers change detection". Like the cd runs all the time even when user is not active in the UI or it runs when you are changing the date? – Daniel Macak Commented Mar 17 at 19:50
  • @Daniel Macak change detection is constantly triggered and causes the app to freeze up – Joseph Coulter Commented Mar 17 at 19:54
  • Can you put together a working example so we can have a look? – Daniel Macak Commented Mar 18 at 6:44
Add a comment  | 

1 Answer 1

Reset to default 0

The repeated change detection with ngModel is a common characteristic of two-way binding with input elements. To reduce it, focus on Using ngModelChange when possible and also try Debouncing method on the date picker selection events.

发布评论

评论列表(0)

  1. 暂无评论