重新加载ULR时,带有Node.js的ngView不会加载主页面

时间:2016-12-26 00:03:46

标签: angularjs node.js router ng-view

在第一次加载时一切正常但是,当我重新加载/刷新页面时,主页面不会加载,只加载模板。

我在尝试重新加载页面时使用Node.js并表示我认为的路由页面:

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>

这是我的路线:

    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 个答案:

没有答案