title: Accessing Spring MVC Model Object in AngularJS
body: <p>I have a Spring MVC web form built using JAVA Spring MVC (Backend) and AngularJS (frontend), JSP(for view) and MySQL DB. A user is able to submit the form after filling it out and search an existing entry. An email is also sent out to the user once the entry has been submitted. The entry also gets saved on a database. In the email body, I am trying to have a link which redirects the user to the form populated with the entries corresponding to the given id..the same way as when the search button is clicked..the form gets populated with the existing form fields..</p>
  
  <p>Currently I wrote a controller which returns the JSP page with the data (searchData)..using ModelAndView however.. it is not populating the form with the details of the entry. How can I achieve this functionality?</p>
  
  <p>I wrote the below code for the controller</p>
  
  <pre><code>@RequestMapping(value = "/searchById", method = RequestMethod.GET)
  public ModelAndView populateEntrydata(@RequestParam(value = "id") String id) {
      String url= "http://localhost:8080/myform/searchById?id=" + id;
      ModelAndView model = new ModelAndView("index"); //jsp page
      ResponseEntity&lt;Data&gt; searchData = search(id);
  
      model.addObject("searchById", searchData);
      // String, String, object
      return model;
  }  
  </code></pre>
  
  <p>How can I access the model object in the angularJS controller so I can populate the jsp with the contents i receive from the ModelAndView?</p>