我試圖配置一個基本的角度應用程序。Angular ngRoute無法正常工作?
我的主HTML:
<html ng-app="CostumerApp">
<head>
<title> Costumers </title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"/>
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Costumer manager</h1>
</div>
<div class="row">
<div class="col-sm-12" ng-view></div>
</div>
</div>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="js/app.js"></script>
<script src="controllers/costumerCtrl.js"></script>
</body>
應用JS
angular.module('CostumerApp', ['ngRoute'])
.config(function ($routeProvider, $locationProvider){
$routeProvider
.when('/costumers', {
controller: 'costumerCtrl',
templateUrl: 'views/list.html'
});
$locationProvider.html5Mode(true);
});
costumerCtrl.js:
angular.module('CostumerApp')
.controller('costumerCtrl', function ($scope){
$scope.costumers = [];
});
列表HTML:
<table class='table table-hover table-hover table-bordered'>
路由不工作, 現在它沒有找到「http://localhost:3000/costumers」當我剛做http://localhost:3000它帶我到項目文件夾,而不是我的主要HTML。
我使用節點http-server並開始像那個http-server -p 3000 -a localhost。 爲什麼我的localhost:3000沒有顯示主頁?
謝謝你!
不應該控制器'costumerCtrl'而不是'listCtrl'? –