question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when opening modal in ngOnChanges

See original GitHub issue

Bug description:

Attempting to open a modal as the result of a change via ngOnChanges results in an:

ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined'. Current value: 'modal fade show'. It seems like the view has been created after its parent and its children have been dirty checked. Has it been created in a change detection hook ?

Link to minimally-working plunker that reproduces the issue:

http://plnkr.co/edit/svQOUKKRvyWlioopFTjy?p=preview

Version of Angular, ng-bootstrap, and Bootstrap:

  • Angular: angular@4.0.3
  • ng-bootstrap: ng-bootstrap@1.0.0-alpha.26
  • Bootstrap: bootstrap@4.0.0-alpha.6

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
abnersouzacommented, Jan 22, 2018

I found a workaround in my case, where i have a login form then pressing key enter i open a NgbModal.

I did the following:

  1. Added the #formElement to the my form html tag
  2. Then in the ts I added @ViewChild(‘formElement’) formElement: ElementRef;
  3. On the Submit event i do the following: this.formElement.nativeElement.ownerDocument.activeElement.blur();

Solved 😃

Tried all the other ways like setTimeout and no success

8reactions
pkozlowski-opensourcecommented, Jun 3, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript - Angular - Modal NgBootstrap ... - Stack Overflow
I used modal of ng-bootstrap, i tried to open the modal when a data send from first component to sencons component in the...
Read more >
NG0100: Expression has changed after it was checked - Angular
This error commonly occurs when you've added template expressions or have begun to implement lifecycle hooks like ngAfterViewInit or ngOnChanges .
Read more >
ngOnChanges only runs when the Input change comes from a ...
ngOnChanges only runs when the Input change comes from a template binding like <component [someInput]="aValue"> .
Read more >
Player Modal Ngonchanges - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Angular Debugging "Expression has changed": Explanation ...
This type of error usually shows up beyond the initial development stages, when we start to have some more expressions in our templates,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found