0

I have a use case to toggle the view of a form using a button. The button is not nested in the same structure of the form, and is out side the scope of the forms controller.

What is the best way to have this toggle button comunicate to the contents controller to display this content?

Vitaly Babiy
  • 6,114
  • 4
  • 26
  • 24
  • Several possible answers here. Need a little more context. Is the form controller a child of the one that holds the button? Are you using directives? Short plunker would allow more specific answers. – S McCrohan Jun 26 '13 at 12:12

1 Answers1

1

I have had a similar problem and for advanced comunications between controllers i would recomend a service. A service can be injected into multiple controllers so they can share information & state.

However if all your after is something like a button that you can place anywhere that will show the form, you could consider using the $location.path?

eg. on a view with a list of users

www.example.com/users

append edit

www.example.com/users/edit

then have the form controller watch the $location.path and open itself when it see's edit ?

Chris Matheson
  • 348
  • 2
  • 7