我想重定向到应用程序的另一个页面。与我们在 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/