npm start:“ReferenceError:angular not not defined”

时间:2015-06-09 01:14:34

标签: javascript angularjs node.js express mongoose

我正在关注https://thinkster.io/mean-stack-tutorial/的教程,当我运行'npm start','node bin / www'或'node angApp.js'时,我得到了名义错误

我运行了以下命令(按顺序):

npm install -g express-generator
express --ejs test
cd test
npm install
npm install --save mongoose

它在我的主文件“angApp.js”的第一行抛出错误:

var app = angular.module('entry', ['ui.router']);

app.controller('main', [
'$scope', 
function($scope) {
    // rider = {name, pickup time, pickup location, drop off location, boolean can ride}
    $scope.riders = [];

    $scope.addRider = function() {
        // make sure to check to see if user submitted nothing
        if(!$scope.inName || $scope.inName == '') {return;}
        if(!$scope.pickTime || $scope.pickTime == '') {return;}
        if(!$scope.locPick || $scope.locPick == '') {return;}
        if(!$scope.dropLoc || $scope.dropLoc == '') {return;}

        $scope.riders.push( {name: $scope.inName, time: $scope.pickTime, 
            pick: $scope.locPick, drop: $scope.dropLoc, canRide: true} );
    };
}]);

我的index.html,现在是index.ejs:

<html>
    <head>
        <title>Dispatching</title>
        <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js"></script>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.js"></script>
        <script src="/javascripts/angApp.js"></script>
    </head>

    <body ng-app="entry" ng-controller="main">

        <div ng-repeat="rider in riders">
            <p>Name: {{rider.name}}</p>
            <p>Pickup time: {{rider.time}}</p>
            <p>Pickup location: {{rider.pick}}</p>
            <p>Drop-off location: {{rider.drop}}</p>
        </div>

        <form ng-submit="addRider()">
            <p>Rider name: <input type="text" ng-model="inName"></input> </p>       
            <p>Pickup time: <input type="text" ng-model="pickTime"></input> </p>
            <p>Pickup location: <input type="text" ng-model="locPick"></input> </p>
            <p>Drop-off location: <input type="text" ng-model="dropLoc"></input> </p>
            <p> <button type="submit">Submit rider</button> </p>
        </form>

    </body>
</html>

我更新了'bin / www':

var app = require('../public/javascripts/angApp');

我的项目结构的根目录:

bin / - 仅包含www

node_modules / - 包含一堆东西

的package.json

public / - 包含目录'images','javascripts','stylesheets',所有这些都是空的,除了包含我的'angApp.js'的javascripts

routes / - 包含'index.js'和'users.js'

views / - 包含'error.ejs'和我的'index.ejs'

我已经在这里多次询问过这个问题了,但大多数解决方案都提出了问题,但是我从未使用它,我甚至不知道我是否拥有它。

0 个答案:

没有答案