Before starting this question, I clarify that I am new so please be patient. I will try to explain myself. In bootstrap I can generate modals in the following way:
[modal.component.html]
<!--<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>-->
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I am trying to create a service
so that I can invoke the previous modal where it requires it.
I imagine something like that inside my service
file.
generatePopup(){
$('#myModal').modal('show');
}
then every time you call the service
(generatePopup
) the modal should appear. I'm not sure how to do this, if you can guide me I would be very grateful.
what I'm trying to do is save code and in any component I do not have to keep the html code in every view, but I do call generatePopup
and it invokes me to the modal.
thanks