Error when toggling NgbDropdown if NgbDropdownToggle was inserted
See original GitHub issueBug description:
If an NgbDropdownToggle is added dynamically, with *ngIf
for example, you get an error when you click the dropdown toggle:
Cannot read property 'anchorEl' of undefined
This issue was mentioned in now closed issue #3297
An easy workaround, for my situation at least, was to move the conditional directive up to the enclosing NgbDropdown element.
Link to minimally-working StackBlitz that reproduces the issue:
https://stackblitz.com/edit/angular-sg77ok
Versions of Angular, ng-bootstrap and Bootstrap:
Angular: 8.1.1
ng-bootstrap: 5.0.0
Bootstrap: 4.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
ng-bootstrap ngbDropdown not working in angular 4
ngbDropdownMenu is property added to "dropdown-menu" div. Share.
Read more >Dropdown - Angular powered Bootstrap
Toggle dropup. Action - 1 ... This option is useful if the dropdown is defined inside an element that clips its contents (i.e....
Read more >Adding Bootstrap 4 Dropdown Menu in Angular Application ...
Check out my gear on Kit: https://kit.com/codewithsriniHow to add a library like bootstrap 4 in Angular 6 applications and use ng-bootstrap ...
Read more >can't bind to 'ngbcollapse' since it isn't a known property of 'div'
As the error states, ngbCollapse is not a property of div , it's a directive included in NgbModule . You have to import...
Read more >displayName & ngIf not working properly - Angular
user$”> directive is supposed to show up only when no user is logged in, but it always not shown, on the other hand...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This also happened with me. Solved adding a
<a ngbDropdownToggle style="display:none" />
to get rid of the error.Change ngbDropdownItem by ngbDropdownAnchor !