Currently I have an Angular.js page that allows searching and displays results. User clicks on a search result, then clicks back button. I want the search results to be displayed again but I can’t work out how to trigger the search to execute. Here’s the detail:

  • My Angular.js page is a search page, with a search field and a search
    button. The user can manually type in a query and press a button and
    and ajax query is fired and the results are displayed. I update the URL with the search term. That all works fine.
  • User clicks on a result of the search and is taken to a different page – that works fine too.
  • User clicks back button, and goes back to my angular search page, and the correct URL is displayed, including the search term. All works fine.
  • I have bound the search field value to the search term in the URL, so it contains the expected search term. All works fine.

How do I get the search function to execute again without the user having to press the “search button”? If it was jquery then I would execute a function in the documentready function. I can’t see the Angular.js equivalent.

14 Answers
14

Leave a Reply

Your email address will not be published. Required fields are marked *