node.js - Node.js 应用程序中未定义 Angular

标签 node.js angularjs

我是一名 Node.js 新手,在完成简单的教程后,我尝试加载一个使用 Node.js 的开源应用程序,但收到以下错误。我确信这是一个微不足道的配置问题,但我没有看到它。

ReferenceError: angular is not defined
    at Object.<anonymous> (d:\projects\nodeapp\app\app.js:7:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

这是发生错误的 app.js。

/**
 * App bootstrap script   <----- START OF FILE
 */

'use strict';

var nodeapp = angular.module('nodeapp', ['ngRoute', 'ngSanitize', 'ngAnimate']);  <----- ERROR

这是index.html

<!doctype html>
<html ng-controller="AppCtrl">
<head>
    <meta charset="utf-8">
    <title>App</title>

    <link href="./visual/css/main.css" rel="stylesheet" type="text/css">

    <script src="./bower_components/jquery/jquery.min.js"></script>
    <script src="./bower_components/angular/angular.js"></script>
    <script src="./bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="./bower_components/angular-route/angular-route.js"></script>
    <script src="./bower_components/angular-animate/angular-animate.js"></script>

    ... more scripts ...

    <script src="./app.js"></script>

</head>
<body class='app-not-ready'>

    <ng-view></ng-view>

    <div class="notification-bar"
        ng-if="notificationBarVisible"
        ng-animate
        ng-bind="notificationMessage"></div>

</body>
</html>

这是文件夹结构

Folder Structure

最佳答案

你只是感到困惑。 =) AngularJS 是前端 JavaScript 框架,仅在客户端(浏览器)上工作。 NodeJS 是一个用于编写服务器端的平台。以 Express 框架上的 NodeJS 应用程序为例。 https://github.com/dizel3d/bicycles 。 首先,您需要安装 NodeJS 及其模块(在命令行 node i 中的项目根目录中运行)。启动 node app.js 并打开 http://localhost:3000

关于node.js - Node.js 应用程序中未定义 Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26108870/

相关文章:

javascript - Cheerio 错误处理程序 Node js

node.js - 验证 Express js 中的表单字段时出现错误消息问题

javascript - 为什么 Angular 在使用不同的字符串时表现出意外?

angularjs - 使用 nghandsontable 访问 Handsontable 方法/属性

javascript - AngularJS。执行长时间运行的任务

javascript - Angularjs 向指令添加样式(使用 Css 文件)

node.js - 使用 winston-mongodb、express-winston 和 winston 进行日志记录

javascript - 如何从 intern.js 测试中加载 node.js http 模块?

node.js - coinbase- Node : Scopes don't match current API version

angularjs - Angular JS ngModel : Transform data