DEV Community

Discussion on: The Principles for Writing Awesome Angular Components

Collapse
 
brooksforsyth profile image
Brooks Forsyth

I find using input output for view only components to be simpler. If I have a parent component whos child component is a button. The input could be the button text and the output would be emitting the click event. Then I can use that button everywhere and customize it.

If I made a service to keep track of button clicks it would require a new file and for that component etc...

I do think passing data thats more complex than that should be handled in a service.

Collapse
 
gc_psk profile image
Giancarlo Buomprisco

I agree, your comment is on point!

I would stress that ideally a dumb component should never access a service for state.

Of course I am quite sure there are situations where a service could be needed

Thread Thread
 
brooksforsyth profile image
Brooks Forsyth

haha I had dumb component written but changed it to view only component. I felt as if dumb may be offensive. Im not sure why components don't have feelings =)

Thread Thread
 
vitale232 profile image
Andrew Vitale

Thanks to you both. The considerations for I/O vs a service make much more sense to me now. Like most thing in programming (and life), it depends!