AngularJS路由不起作用

时间:2016-01-29 08:24:00

标签: javascript html angularjs angularjs-routing

我无法在我的页面中实现angularJS路由,当我第一次创建它时,它可以工作,但是在浏览器没有返回任何内容之后。 码: http://plnkr.co/edit/lIXeC0X6SkzXKcr8hoAp?p=catalogue

应用程式:

    angular.module('$routingApp', ['ngRoute'])
        .config(['$routeProvider', function($routeProvider){
            $routeProvider
            .when('/', {
                templateUrl: 'main.html'
            })
            .otherwise({
                redirectTo: '/'
            });
        }]);

1 个答案:

答案 0 :(得分:2)

问题在于您的模块名称,正如@ sp00m所建议的那样,请参阅下面更新的plunkr链接:

angular.module('routingApp', ['ngRoute'])
    .config(['$routeProvider', function($routeProvider){
        $routeProvider
        .when('/', {
            templateUrl: 'main.html'
        })
        .otherwise({
            redirectTo: '/'
        });
    }]);

PLUNKR