Angularjs 无法使用我的meanstack应用程序获取ngRoute
我注意到这是一个很受欢迎的问题,我已经看了前面所有的问题,据我所知,没有一个能帮助我解决问题 当我访问URL localhost:3000/about时,我无法让页面加载partials下的about页面 这是我尝试访问localhost:3000/about时收到的消息: 不能走动 我的文件夹结构如下: 这是我的app.js文件:Angularjs 无法使用我的meanstack应用程序获取ngRoute,angularjs,ngroute,Angularjs,Ngroute,我注意到这是一个很受欢迎的问题,我已经看了前面所有的问题,据我所知,没有一个能帮助我解决问题 当我访问URL localhost:3000/about时,我无法让页面加载partials下的about页面 这是我尝试访问localhost:3000/about时收到的消息: 不能走动 我的文件夹结构如下: 这是我的app.js文件: /*global angular:true */ angular.module('myApp', [ 'AppCtrl', 'ngRoute' ]).con
/*global angular:true */
angular.module('myApp', [
'AppCtrl',
'ngRoute'
]).config(['$routeProvider', function($routeProvider) {
$routeProvider.
when("/", {templateUrl: "index.html"}).
when("/about", {templateUrl: "partials/about.html"});
}]);
这是我的index.html文件:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>New Meanstack APP</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
</head>
<body>
<div class="container" ng-controller="AppCtrl">
<h1>MeanStack App</h1>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Number</th>
<th>Action</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" ng-model="contact.name"></input>
</td>
<td>
<input class="form-control" ng-model="contact.email"></input>
</td>
<td>
<input class="form-control" ng-model="contact.number"></input>
</td>
<td><button class="btn btn-primary" ng-click="addContact()">Add Contact</button></td>
<td><button class="btn btn-primary" ng-click="update()">Update</button> <button class="btn btn-info" ng-click="deselect()">Clear</button></td>
</tr>
<tr ng-repeat="contact in contactlist">
<td>{{contact.name}}</td>
<td>{{contact.email}}</td>
<td>{{contact.number}}</td>
<td><button class="btn btn-danger" ng-click="remove(contact._id)">Remove</button></td>
<td><button class="btn btn-warning" ng-click="edit(contact._id)">Edit</button></td>
</tr>
</tbody>
</table>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
<script src="app.js"></script>
<script src="scripts/angular-route.min.js"></script>
<script src="controllers/controller.js"></script>
<script src="scripts/jquery.min.js"></script>
</body>
</html>
编辑:
如果未使用ng view,则路由提供程序希望在ng view中渲染视图。如果你需要帮助,我有一个迷你平均堆栈设置
角度代码位于public/js中
视图模板是公共的/u
请注意,登录只是为了演示如何传输数据和完成角度路由。据我所知,登录不符合Oauth标准,还没有验证您的ng视图在哪里?我删除了其中的那一部分,以避免混乱。ng视图直接位于.container divAh下。好的,这就是我期望的位置。您是否尝试过通过localhost:3000//about访问您的站点?它只需将我转到主页index.html即可
var express = require('express');
var app = express();
var mongojs = require('mongojs');
var db = mongojs('contactlist', ['contactlist']);
var bodyParser = require('body-parser');
app.use(express.static(__dirname + "/public"));
app.use(bodyParser.json());