I want to create project with using Spring boot + rest + angularJS, I did whole back end with rest, I'm using angular first time and I watched a lot of tutorials for creating UI, so, I did all as in many tutorials but anyway it doesnt work and I cannot understand why because event doesnt exist an error I'm sitting 2 days for solving problem and I'm crushed. I don't know what to do. Please, someone help me to set up routeProvider correct, I downloaded whole angular libs and put in project. So, take a look please.
My app.js
var myApp = angular.module('myApp',['ngRoute']).
config(function($routeProvider,$locationProvider){
$locationProvider.html5Mode(true);
$routeProvider.when("/books/", {templateUrl:"/templates/book/list.html"})
}
);
My book.html, I did img because I want you see that tag isn't readable:
and list.html:
And when I go to localhost:8080/books/ it gives me Json value from RestController and no any error like 404 or anything.
Try to put a controller for each view. Add this:
$routeProvider.when(
"/books/",
controller: 'YourBooksController',
{templateUrl:"/templates/book/list.html"}
)
However i strongly suggest you to use ui router .
The Spring Boot + AngularJS documentation is pretty good: Spring and Angular JS: A Secure Single Page Application . This tutorial includes a simple router that you can use as an example for resolving your issues.
For full featured application example code try JHipster .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.