//quote-generator-app.service.ts
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class QuoteGeneratorAppService {
private quotes = [
{
text: 'The only limit to our realization of tomorrow is our doubts of today.',
author: 'Franklin D. Roosevelt',
},
{ text: 'The purpose of our lives is to be happy.', author: 'Dalai Lama' },
{
text: "Life is what happens when you're busy making other plans.",
author: 'John Lennon',
},
{ text: 'Get busy living or get busy dying.', author: 'Stephen King' },
{
text: 'You only live once, but if you do it right, once is enough.',
author: 'Mae West',
},
{
text: 'Many of life’s failures are people who did not realize how
close they were to success when they gave up.',
author: 'Thomas A. Edison',
},
{
text: 'If you want to live a happy life, tie it to a goal, not to people or things.',
author: 'Albert Einstein',
},
{
text: 'Never let the fear of striking out keep you from playing the game.',
author: 'Babe Ruth',
},
{
text: 'Money and success don’t change people;
they merely amplify what is already there.',
author: 'Will Smith',
},
{
text: 'Your time is limited, so don’t waste it living someone else’s life.',
author: 'Steve Jobs',
},
{
text: 'Not how long, but how well you have lived is the main thing.',
author: 'Seneca',
},
{
text: 'If life were predictable it would cease to be life, and be without flavor.',
author: 'Eleanor Roosevelt',
},
{
text: 'The whole secret of a successful life is to find out what is
one’s destiny to do, and then do it.',
author: 'Henry Ford',
},
{
text: 'In order to write about life first you must live it.',
author: 'Ernest Hemingway',
},
{
text: 'The big lesson in life, baby, is never be scared of anyone or anything.',
author: 'Frank Sinatra',
},
];
constructor() { }
getRandomQuote(): Observable<string> {
const randomIndex = Math.floor(Math.random() * this.quotes.length);
const selectedQuote = this.quotes[randomIndex];
return of(`"${selectedQuote.text}" - ${selectedQuote.author}`);
}
}