Hi Thanks for your response. Im not sure I can get it working from plunker but I have done what I can here <http://plnkr.co/edit/IlJywWSYTmokulLnL3Wm?p=info>
I have a search Factory, you type in the destination, arrival and departure dates and when it is pressed it will save the form data as a session cookie and then fire a function in the hotels service (makes the API call) and then redirects you to the hotels page. The hotelsFactory picks up the session cookie, pulls in API settings such as an API_key, Id etc then builds the string and data needed to then make an API request to a 3rd party vendor via ajax (couldnt use a data object for some reason so had to make a load of vars). This all works correctly though. However the search button instantiates the function and runs the code (not the hotelsController) so when the the hotels page is hit the function to retrieve the data is is already made by the controller so the call either is made twice or the hotelsController runs the function before the search button can do its thing. I have tried to make the search button go to the hotels controller but cant seem to inject a controller into another controller and execute a function from it. *Search button pressed -> runs function to make API call -> hotelsController picks up returned data to be displayed in veiw????* -- 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 http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
