使用NodeJS和Express引导AngularJS 1.6.2时找不到文件

时间:2017-03-05 14:53:57

标签: angularjs express controller bootstrapping

我正在尝试设置AngularJS应用程序但是在引导它时我一直遇到问题,我能够通过节点在快速服务器上运行它。

但是当我去启动一个控制器时,我的开发人员工具控制台不会在控制台中返回控制台记录的hello世界。

我似乎无法解决这个问题(据我所知)正确地写出来。我使用了ng-app和ng-view,并尝试使用ng-controller调用控制器名称来实例化它。

文件结构:

enter image description here

HTML:

<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Contact List App</title>
</head>
<body>

<div class="container" ng-controller="AppCtrl" ng-view>
    <h1>Contact List App</h1>

    <table class="table">
        <thead>
            <tr>
                <th>Name</th>
                <th>Email</th>
                <th>Number</th>
            </tr>
        </thead>
    </table>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.min.js"></script>
<script src="controllers/controller.js"></script>
</body>
</html>

控制器:

var myApp = angular.module('myApp', []);

myApp.controller('AppCtrl', ['$scope', '$http', function($scope, $http) {
    console.log("Hello World from controller");
}]);

错误:

enter image description here

编辑:我在这里添加了server.js代码:

var express = require('express');
var app = express();

app.use(express.static(__dirname + '/public' ));

app.listen(3000);
console.log('Server running on 3000');

0 个答案:

没有答案