我想重定向到应用程序的另一个页面。以与在MVC应用程序或asp.net应用程序中类似的方式进行。我已经定义了下面的Route.js文件。

通过以下方式定义的route.js

var MainApp=angular.module('RoutingApp', ['ngRoute'])
    .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
        $routeProvider
            .when('/BusinessAgent', {
                templateUrl: 'Views/BusinessAgent/BusinessAgent.html',
                controller: 'BusinessAgentController'
            })
        .when('/Admin', {
            templateUrl: 'Views/Admin/Admin.html'
        })
            .otherwise({
                redirectTo: '/'
            });
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });
    }]);


HTML页面

 <section id="banner">
        <ul class="actions">
                    <li>
                        <a href="#BusinessAgent" class="button big">Business Agent</a>
                    </li>
                </ul>
    </section>


单击href时,它应该重定向。但是它没有被重定向。

最佳答案

我认为您缺少ng-view。添加ng-view进行路由。它充当占位符

<div ng-view></div>

关于javascript - 我想使用有 Angular JS重定向到另一个页面,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35128515/

10-11 06:08
查看更多