ngView with Node.js doesn't load the main page when the ULR is reloaded

77 views Asked by At

In the first load everything is okay but, when I reload/refresh the page the main page don't load and only the template load.

I use Node.js and express for route pages I think when I try reload page:

app.get('/', function (req, res) {
res.render('index.html');   
console.log('GET: 200 index');
console.log(req.statusCode);


<div class="container conteudo btn-group btn-group-lg" ng-controller="routeCtl">
        <a class="btn btn-default" ng-class="{active: isActive('/cadastro/cadastro')}" href="/cadastro/cadastro">{{lnkCadastrar}}</a>
        <a class="btn btn-default" ng-class="{active: isActive('/login/login')}" href="/login/login">{{lnkAcessar}}</a>
        <a class="btn btn-default" ng-class="{active: isActive('/home/home')}" href="/home/home">{{lnkHome}}</a>

    </div>

    <div ng-view class="container divNgView"></div>

This is my route:

    var appRoute = angular.module('appRoute', ['ngRoute'])
    .config(['$routeProvider', '$locationProvider',
        function($routeProvider, $locationProvider) {

            $routeProvider.when('/footer', {
                templateUrl: '../views/footer.ejs'
            }).when('/login/login', {
                templateUrl: '../views/login/login.html',
                controller: 'loginCtl'
            }).when('/cadastro/cadastro', {
                templateUrl: '../views/cadastro/cadastro.html',
                controller: 'cadastroControll',
                controllerAs: 'cadastroCtl',
                reloadOnSearch: false
            }).when('/home/home', {
                templateUrl: '../views/home/home.html',
                controller: 'homeControll'
            }).when('/*', {
                templateUrl: '../views/error.ejs'
            });


            $routeProvider.otherwise({
            }).otherwise({
                redirectTo: '/index.html',
                reloadOnSearch: false
            });

            $locationProvider.html5Mode({enabled: true, requireBase: false});


        }]);

appRoute.controller('appRouteCtl', ['$scope', function ($scope) {
    $scope.title = "Controlador de Patio";
}]);
0

There are 0 answers