I am taking my first steps in Angular and I made a quote generator which is working fine; Now I want to add a button when clicked copies to clipboard the generated quote. I check some few links about copying to clipboard such as Angular 5 - Copy to clipboard but I do not know how to use it in my case.
This is the part in app.component.ts
for the random part.
getNewQuote($event: MouseEvent) {
const quoteText = document.querySelector('.quote-text');
this.randomNumber = Math.floor(Math.random() * (this.quotes.length));
quoteText.innerHTML = this.quotes[this.randomNumber];
I have this in app.component.html
for the copy button
<i class="fa fa-files-o" (click)="copy()"></i>
I am very stuck on this I do not know how to copy the random quotes. How can I do this?