Hello! I have a weird problem that I cannot understand. I hope someone can help me.
Plunker: http://plnkr.co/edit/e9B6jc - for some reason, I cannot reproduce the situation in plunker, but since it's created, I leave it here to show the setup and data expected. The setup is this: A. Server with an API. B. Server with the web interface with angular. The process is like this: 1. I make a GET request to the API (/api/employees/{guid}) , which returns data like the *employee.json* in the plunker. I'm using ngResouce (angular-resource) to query the API. 2. It gets intercepted by the HttpInterceptor, which adds some required headers to the request. 3. When the server returns the data (server response), the response is again intercepted by the HttpInterceptor. It does some things and rejects or continues depending on the status. 4. When it continues, the data is simply passed back to the controller. My problem is between 3 and 4: when the response is intercepted (3), I log the data (as shown in the script.js of the plunker, line 35) and, randomly, I get the *response.data.account.roles* empty. I'm sure that the *roles* array is not empty, because when I inspect the data in the Developer Tools (Google Chrome, Network tab), the response contains all data. Even in the API logs (on the server side) the *roles* array is not empty. The weird thing is that when I log the intercepted response, the response.data.account.roles MAY be empty (yes, not always). However, if I log the object explicitly (using response.data.account.roles) the array is never empty. In the UI, I use angular to show the full object (index.html of the plunker, line 17) and sometimes the *account.roles* is empty. I say *sometimes* because it happens when I reload the page. This, of course, causes problems in the UI, because the response.data.account.roles is sometimes empty, and I need it to set the selected items of a select element. I hope someone can enlighten me, because I can't figure it out :( Thanks to everyone who reads this. -- You received this message because you are subscribed to the Google Groups "AngularJS" 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.
