I'm running a system running locally, done in Spring Java boot on the back end and Angular on the front end. But I have a problem occurring on the front end that is as follows:
When I raise my application and access the localhost/clinica/
I'm redirected to my index that loads my home.html
; So far so good. The page loads neatly with menus and information.
The url looks like this: http://localhost/ultravitae/#!/
In the menu I have a Profile option; When I click I should list the profiles but nothing appears. It's on the same previous page. However the url changes, thus: http://localhost/ultravitae/#!/#%2Fperfil
As far as I can see, it's like concatenating the url. Has anyone experienced this and knows how to solve it?
My index.js
looks like this:
'use strict';
angular.module('clinica',['ngRoute'])
.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'src/home/home.html',
controller: 'HomeCtrl'
})
.when('/perfil', {
templateUrl: 'src/perfil/perfil.html',
controller: 'PerfilCtrl'
})
.otherwise({
redirectTo: '/'
});
});
My home.js like this:
'use strict';
angular.module('clinica')
.controller('HomeCtrl', function() {
});
And my profile.js like this:
'use strict';
angular.module('clinica')
.controller('PerfilCtrl', function($scope, $http){
$scope.perfils = [];
$http.get('http://localhost:8080/api/private/perfil').then(function(response){
$scope.perfils = response.data;
});
});
In my index.html
I have a div
that should display the content
<div id="main">
<ng-view />
</div>
The folder structure looks like this:
ultravitae (arquivos: index.html e index.js)
|-> src
|-> home (arquivos: home.html e home.js)
|-> perfil (arquivos: perfil.html e perfil.js)
Note: I did the following test. In index.js
I put for my index to call perfil.html
instead of home.html
and listed the profiles right:
angular.module ('clinic', ['ngRoute'])
.config (function ($ routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'src/perfil/perfil.html',
controller: 'PerfilCtrl'
})
.when('/perfil', {
templateUrl: 'src/home/home.html',
controller: 'HomeCtrl'
})
.otherwise({
redirectTo: '/'
});
});