Closed alextsg closed 8 years ago
Good question indeed! If you can, use bindings
as much as possible and think about stateless/stateful components. Using require
kind of goes against the principles of pure components, and inheriting controllers isn't as easy to test, or as reliable IMO (due to DOM placement etc).
Yeah makes a lot of sense. Thank you!
Anytime :)!
Hi @alextsg @toddmotto I guess using 'require' makes sense when you want to utilize a directive API (like a service, e.g. custom logger API) which is not a parent to the component. Also require supports multiple API's to be referred. To access parent scope, 'bindings' are helpful and minimal. Please correct me if am wrong.
I noticed that in the components section, it states that the
require
object is for referencing inherited logic alongside$onInit
. What's the recommendation for usingrequire
versus putting a function in the component'sbindings
? For example, should I be doing:or
Thanks! Sorry if this is the wrong place for this!