I'm encountering a 404 error when trying to load a file in the ng-view route in AngularJS with Spring. As a newcomer to both technologies, I'm struggling to find a solution.
app.js
app.config(function($routeProvider) {
console
$routeProvider.when('/', {
controller : "loginController",
templateUrl : "/pages/login.html"
})})
loginController:
app.controller('loginController', function($scope, $http) {
$scope.companies=null;
$http.post('http://localhost:8080/').success(function(data) {
$scope.companies = data;
console.log(data);
}).error(function(err) {
console.log(err)
});
})
Java Controller:
@Controller public class LoginController {
@Autowired
Facade facade;
@RequestMapping(value = Paths.Public.PATH_ALL_COMPANY, produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
public @ResponseBody List<CompanyDto> allCompany() {
return facade.allCompany();
}
@RequestMapping(value=Paths.Public.PATH_HOMEPAGE,method=RequestMethod.GET)
public String getindexPage(){
return "index";
}
@RequestMapping(value=Paths.User.PATH,method=RequestMethod.GET)
public String getindexPageqs(){
return "index";
}
}
app module:
var app = angular.module("myApp", [ 'ngRoute' ]);
app.config(function($routeProvider) {
$routeProvider
.when('/', { controller : "loginController", templateUrl : "/pages/login.html" })
.when('/user', { controller : "UserHomeController", templateUrl : "pages/user.html" })
.when('/admin', { controller : "AdminHomeController", templateUrl : "pages/admin.html" }
);
HTML:
<body ng-app="myApp">
<script src="modul/angularJS-1.2.32/angular.min.js" type="text/javascript"></script>
<div ng-view></div>