I have an Angular 8 project that is using bootstrap. I am trying to show the modal dialog inside my component using the $('myModal').modal('show') inside my component's Typescript file.
Here's my component's file:
import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
// import * as $ from 'jquery';
import * as bootstrap from 'bootstrap';
@Component({
selector: 'app-xyz',
templateUrl: './xyz.component.html',
styleUrls: ['./xyz.css']
})
export class XyzComponent implements OnInit {
constructor(private router: Router) {
}
ngOnInit() {
}
submit() {
$('#confirm').modal('show');
}
}
Upon invoking the submit() funciton on click I get the following error: ERROR TypeError: $(...).modal is not a function
I installed bootstrap and jquery using npm install bootstrap --save and npm install jquery --save.
I even installed ngx-bootstrap.
However, when I uncomment the line importing jQuery I get a different error: ERROR TypeError: jquery__WEBPACK_IMPORTED_MODULE_3__(...).modal is not a function
ngx-bootstrapconsider using their modal. Try not to mix jQuery and Angular, generally you don't need to. - UncleDave