I need to close my modal window from the angular component, after successfully recording; but the code doesn't work for me; how can I do?
Angular CLI: 6.0.8
Node: 10.16.3
OS: win32 x64
--exp.component.html
<div class="modal fade bd-example-modal-lg" id="modalExperience" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="myExtraLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
--exp.component.ts
import { Component, OnInit, Injectable, Inject, ElementRef } from '@angular/core';
import Swal from 'sweetalert2';
private element: any;
constructor(
private el: ElementRef, @Inject('BASE_URL') baseUrl: string
) {
this.url = baseUrl;
this.element = el.nativeElement;
}
Swal.fire({
title: 'Great',
html: res.mensaje,
type: 'success'
}).then((result) = > {
if (result.value) {
//close modal -- it does not work
this.element.style.display = 'none';
document.body.classList.remove('modalExperience');
}
});
With this code all the windows are closed, I see that it affects the selector of the component and the dark shadow of the modal remains. Please tell me what is the right way!