0

I'm trying to find a way that I can share data between directives within a page. Like:

Parent --Child ----GrandChild --Child ----GrandChild

Child is same directive being reused and Grandchild might have smaller directives inside. My first attempt was using Two way binding between Child and Grandchild, but I see most people use Factory to share data so I wonder which method is better? If I want to go with using Factory, how can I make each Child their own Factory services?

concuagia
  • 5
  • 1
  • I would stick with 2 way binding. A factory or service is used more to share data between pages (controllers) rather than directives contained on the same page and presumably the same controller. – jbrown Oct 05 '17 at 18:43
  • I think in this situation 2 way data binding is a better approach. A Factory is a Singleton, so I don't think that it's a very good approach to share data between multiple directives in the same page, depends on you structure this can get very complex. – L. Figueredo Oct 05 '17 at 20:06

0 Answers0