That's a strange implementation. Your quote-box should be only a "display" component. It doesn't need getNewQuote() function as an input. To implement it properly in Angular, you would create getNewQuoteClick output/event emitter in your "quote-box" component and then when the event is triggered you would set a new quote from your parent component. Also, it might be a good idea to introduce a new service for getting quotes instead of putting all the logic in the app.component.ts. And one more small remark: we use HttpClient service in Angular instead of fetch().
Thanks for the great info and suggestions here! I'll fix these things and update soon. I knew something was a bit off, but now that you bring some of that up, I'm wondering how I didn't think of it. Cheers!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's a strange implementation. Your
quote-box
should be only a "display" component. It doesn't needgetNewQuote()
function as an input. To implement it properly in Angular, you would creategetNewQuoteClick
output/event emitter in your "quote-box" component and then when the event is triggered you would set a new quote from your parent component. Also, it might be a good idea to introduce a new service for getting quotes instead of putting all the logic in theapp.component.ts
. And one more small remark: we useHttpClient
service in Angular instead offetch()
.Thanks for the great info and suggestions here! I'll fix these things and update soon. I knew something was a bit off, but now that you bring some of that up, I'm wondering how I didn't think of it. Cheers!