-1

I had started work on angularjs.Currently i am stuck on some point like how to communicate with directive to controller/service/factory.

My use case was like, I have custom directive with its 5 to 7 attributes(Properties). On my page i want to load directives with reference to JSON data file. So my pages contains different directive. If users modify directive properties and user save file then that file will be generated with updated json data and AJAX call can save that file.

For above case please suggest me approach.

How can i get directive properties in factory/service ?

if i modify my directive property it will also change in factory/servie for very next json data for file.

  • Look here, maybe you can find here your answer https://docs.angularjs.org/tutorial. – Oleksandr Verhun Mar 04 '15 at 07:38
  • @OleksandrVerhun : Thanks For you replay... But i have multiple directive in page and that can communicate with its own object... Once i call that object getJSON method that return particular directive attributes data. So, I want to manage multiple directive with its objects. Please suggest me way for that.. – Gaurav Ashara Mar 04 '15 at 09:48

1 Answers1

0

I opt to use services to communicate between controllers, here are a couple of good articles:

Share data between AngularJS controllers

https://egghead.io/lessons/angularjs-sharing-data-between-controllers

https://github.com/pviraj/Angular-Service-To-Share-Data-Beween-Controllers

Community
  • 1
  • 1
Oam Psy
  • 8,555
  • 32
  • 93
  • 157
  • Thanks For you replay... But i have multiple directive in page and that can communicate with its own object... Once i call that object getJSON method that return particular directive attributes data. So, I want to manage multiple directive with its objects. Please suggest me way for that... – Gaurav Ashara Mar 04 '15 at 09:45