I am trying to add dropdown to a div. The html code (dropdown is an example) is dynamic code. Even though on clicking it shows the dropdown button but the dropdown isn't working. Following is my code from component file
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
@ViewChild('showfilters') el:ElementRef;
this.el.nativeElement.innerHTML = this.el.nativeElement.innerHTML + `
<div class="dropdown " dropdown>
<a class="dropdown-toggle text-light" dropdownToggle> New Dropdown</a>
<div class="dropdown-menu mt-2 mr-3" *dropdownMenu>
<a class="dropdown-item"> Profile</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item"><i class="fa fa-sign-out"></i>New</a>
</div>
</div>
`;
My html
<div class="showfilters" #showfilters>
I have created an example on StackBlitz too.