I'm developing some project using angular and spring boot and I have some confussing situation:
I have Spring Controller to share view file names with my application
@Controller
public class OfferViewController {
@RequestMapping(value = "/addOffer", method = RequestMethod.GET)
public String addView() {
return "html/offer/addOffer";
}
@RequestMapping(value = "/showOffer/{offerId}")
public String showOffer(@PathVariable("offerId") String offerId){
return "html/offer/showOffer";
}
}
And I have some other controller to handle REST calls:
@RestController
public class OfferRestController {
private OfferRepository offerRepository;
@Autowired
public OfferRestController(OfferRepository offerRepository) {
this.offerRepository = offerRepository;
}
@RequestMapping(value = "/showOfferJson/{offerId}", method = GET, produces = APPLICATION_JSON_VALUE)
public Offer showOffertest(@PathVariable("offerId") String offerId) {
Offer offer = offerRepository.findOne(offerId);
return offer;
}
@RequestMapping(value = "/saveOffer", method = POST)
public ResponseEntity<Offer> saveOffer(@RequestBody Offer offer) {
Offer offerSaved = offerRepository.save(offer);
return new ResponseEntity<Offer>(offerSaved, HttpStatus.OK);
}
}
I use angular for develope my UI.
I find myself confused when I start to read about routing possibilities in angular (single page application stuff) so as I assume i dont need OfferViewController any more.
My question are:
Should I have an single index.html page to manage all ng-routes? For example ngRoute first to addOffer.html second to contact.html etc.?
Do I still need Controller to provide my starting page with all ngRout'ings?
Mby I'm wrong so please give me an advice how to do ngRouting right.
Thank You for any help!