gpt4 book ai didi

javascript - 我想使用 Angular JS 重定向到另一个页面

转载 作者:行者123 更新时间:2023-11-28 11:02:23 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com