Hi,
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 initializes 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 to replicate the issue* 1. 1.Select the Bank Tab under the order row, say order no 10248, choose the first bank row under this order 2. 2.Click edit link, first time works fine by showing data in the form. Close the popup form by selecting X icon in the top right corner 3. 3.Select any other bank row , you will see stale data reflecting, the data is always that of the first bank that was selected. -- 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.
