I have been researching this for a few days and I still haven't been able to resolve this issue. I want to be able to open up a modal based upon the selection of the dropdown menu. I am trying to use the modal service from NgbModal library. Using the example from the documentation. When I place the modal button inside of a dropdown it not catching the event. So I made a conditional statement based upon what the user selects in the dropdown menu. The problem is, I do not know how to pass the modal content in properly. In the example they used a thumbnail with a ng-template and pass the content when the modal button is clicked. Since this button is now an option in a select component. When I select the right dropdown option the screen goes dark, but no modal appears because the content is not defined any help would be greatly appreciated.
import {component, OnInit, Input} from '@angular/core'
import { NgbModalConfig, NgbModal, NgbActiveModal} from 'ng-bootstrap/ng-bootstrap'
@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
styleUrls: ['./nav.component.css']
})
export class NavComponent implements OnInit {
@Input('event') event: any;
constructor(public modalService: NgbModal){
this.fileMenu = [];
};
changeMenu(e) {
if (e.target.value === 'Launch Demo Modal'){
this.modalService.open(content)
}
}
}
HTML
<nav class="navbar navbar-expand navbar-dark">
<select class= "nav-drop (change)= "changeMenu($event)">
<option> File </option>
<option> Launch Demo Modal </option>
</select>
</nav>