I'm making a web app: front-end in Angular and back-end in Rails. When the user comes to my web app, I am going to show the pop up on top left. When user clicks "copy the code" button, the promo code should be copied to their laptop or desktop.
Here is view for the modal(I'm not adding CSS since it is not important for this question):
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content" style="text-align:center">
<div class="modal-header">
<span class="close">X</span>
<h2>Welcome Hunt users!</h2>
</div>
<div class="modal-body">
<p>$50 off.</p>
</div>
<div>
<button class="button button-form-success button--orange vertical-offset--teensy modal-button">Yes
</button>
</div>
</div>
</div>
Javascript file
var promocode = "promocode"
function copyPromo () {
// business logic to copy the promocode to user's computer
}
I am trying to figure out how to copy promocode
variable to user's computer but I cannot figure it out. I would appreciate any advice!