我是angularjs的新手。最近我练习角度,所以我的出发点是路由。 &安培;我从这个链接看到/home/rafat/Downloads/Wildlife-Night.tmTheme
我的路线提供商文件如下所示。
var sampleApp = angular.module('phonecatApp', []);
sampleApp .config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/addOrder', {
templateUrl: 'templates/add-order.html',
controller: 'AddOrderController'
}).
when('/showOrders', {
templateUrl: 'templates/show-orders.html',
controller: 'ShowOrdersController'
}).
otherwise({
redirectTo: '/addOrder'
});
}]);
&安培; HTML,
<!DOCTYPE html>
<html lang="en">
<head>
<title>AngularJS Routing example</title>
</head>
<body ng-app="sampleApp">
<div class="container">
<div class="row">
<div class="col-md-3">
<ul class="nav">
<li><a href="#AddNewOrder"> Add New Order </a></li>
<li><a href="#ShowOrders"> Show Order </a></li>
</ul>
</div>
<div class="col-md-9">
<div ng-view></div>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="app.js"></script>
</body>
</html>
但它不起作用;我该如何解决这个问题?
答案 0 :(得分:1)
<li><a href="#AddNewOrder"> Add New Order </a></li>
<li><a href="#ShowOrders"> Show Order </a></li>
你应该:
<li><a href="#/addOrder"> Add New Order </a></li>
<li><a href="#/showOrders"> Show Order </a></li>
答案 1 :(得分:1)
a href
中的nav
个属性错误。应该是:
<ul class="nav">
<li><a href="#/addOrders"> Add New Order </a></li>
<li><a href="#/showOrders"> Show Order </a></li>
</ul>
答案 2 :(得分:1)