Hello Angular Experts,


I'm using a service to share data between two controllers. I'm sharing data 
between BankController and CreateBankController.

What I observe is that the CreateBankController ininitialises and creates 
an instance of the Popup Service (sharedservice). Since its a singleton, 
the Popup Service does not instantiate every time, so it' now holds stale 
data in the CreateBankController. I can see the data getting set into my 
Popup Service, but CreateBankController has a stale instance of Popup 
Service that was created the first time. I suppose since its a singleton 
that is the expected behavior.

Couple of queries with the approach I have taken

   1. 
   
   1. Firstly, Is this the correct approach to take to share data between 
   two controllers? Please check bank. create.controller.js for the complete 
   code. Is there a better approach to take?
   2. 
   
   2. Should I have a broadcast method to broadcast changes to my Popup 
   Service whenever I set it. Is this the approach to take? Will the Popup 
   Service instance in CreateBankController be updated with the changed data 
   if I call into the broadcast method? Appreciate if you could show me 
   through changes in plunker or any code samples as I am trying to understand 
   the broadcast method implementation.
   
*PLUNKER LINK* 

https://plnkr.co/edit/fCt83O?p=preview



Steps

   1. 1. Under the order row, select the Bank Tab, choose any of the first 
   few orders' bank rows.
   2. 2. Click edit link, first time works fine.
   3. 
   
   3. Select any other row , you will see stale data reflecting.
   
Thanks
Kar

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to