Angularjs route

Asked

Viewed 49 times

0

I have a web application in spring boot and use Angular on the routes. Everything is working, but when I update the page, if not on home, presents an error and when I change something in some HTML file, it does not appear.

Routes

var app = angular.module('appRadio',['ngRoute']);

app.config(function($routeProvider, $locationProvider) {
    // remove o # da url
    $locationProvider.html5Mode(true);

    $routeProvider

    .when("/", {
        templateUrl : "app/views/home.html",
        controller  :"HomeCtrl",
    })
    .when("/enviarMusicas", {
        templateUrl : "app/views/enviarMusicas.html",
        controller  : "enviarMusicaCtrl"
    })
    .when("/contato", {
        templateUrl : "app/views/contato.html",
        controller  : "ContatoCtrl"
    })
    .when("/musicas", {
        templateUrl : "app/views/musica.html",
        controller  : "MusicaCtrl"
    })
    .otherwise({
        redirectTo: "/"
    });
});

Controllers

app.controller('MusicaCtrl', function($scope,$rootScope, $location,$http) {
    $rootScope.activetab = $location.path();

    $(document).ready(function() {
        $('#tabela').DataTable( {
            "scrollY":        "300px",
            "scrollCollapse": true,
            "paging":         false
        });
    });

    $http.get("/musica/buscarTodas").then(function(response) {
        $scope.musicas = response.data;
        console.log($scope.musicas);
    },function(err){
        console.log(err);
    });
});

app.controller('HomeCtrl', function($scope) {
    $scope.path = $location.path();
});

app.controller('enviarMusicaCtrl', function($scope,$rootScope, $location) {
    $rootScope.activetab = $location.path();

    $scope.tipos = [
        {valor:"Mp4"},
        {valor:"Mp3"},
        {valor:"CD"},
        {valor:"DVD"},
        {valor:"JPG"},
        {valor:"PNG"}
    ];

    $scope.musica;
});

app.controller('ContatoCtrl', function($rootScope, $location) {
    $rootScope.activetab = $location.path();
});
  • I don’t understand ,I’m new with angular . rsrs

  • Basically this is it: If you use $locationProvider.html5Mode(true); to remove the '#' marker you need to set, on the home page, an element base, in addition to other possible server-side settings.

  • at index ta <base href="/" />

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.