大家好我正在使用angularjs并使用路由功能(路由提供商)它只在我第一次点击第二个菜单时没有重定向工作,我也没有收到任何错误控制台帮助如何在这里解决我附加我的代码
<!DOCTYPE html>
<html ng-app="app" >
<head>
<script src="assets/js/AngularJS1.3.12.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>
<script src="controller/module.js"></script>
</head>
<body class="no-skin" >
<a href="#/managerole">role</a>
or
<a href="#/manageuser">user</a>
<div ng-view></div>
</body>
</html>
var app = angular.module("app", [ "ngRoute"]);
// configure our routes
app.config(['$routeProvider','$locationProvider','$httpProvider',function ($routeProvider,$locationProvider, $httpProvider) {
$locationProvider.hashPrefix('');
// route for the about page
$routeProvider
.when('/', {
templateUrl: 'UnderConstruction.html'
})
.when('/managerole', {
templateUrl: 'role.html',
controller: 'RoleViewCtrlq'
})
.when('/manageuser', {
templateUrl: 'user.html',
controller: 'UserController'
});
}]);
app.controller('RoleViewCtrlq', function($scope) {
$scope.message = 'Look! I am an Role page.';
});
app.controller('UserController', function($scope) {
$scope.message ='Look! I am an user page.';
});
答案 0 :(得分:0)
根据您的代码,您忘记在Html页面中添加ng-view标记
以下是帮助您的示例
https://www.w3schools.com/angular/tryit.asp?filename=try_ng_routing_controller
答案 1 :(得分:0)
请试试这个:
<body class="no-skin" >
<a href="#!managerole">role</a>
or
<a href="#!manageuser">user</a>
<div ng-view></div>
</body>