0

您好,我是 Java 脚本的新手。我的小组成员编写了一些代码来为一个项目创建一个网站,我想在我的笔记本电脑上运行它。我们在客户端使用 AngularJS。但我收到以下错误:

ReferenceError: angular is not defined
at Object.<anonymous> (C:\Users\Usman\Desktop\temp_course_rating\temp_course
_rating\public\app.js:2:11)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

我已经粘贴了该特定文件中的代码。我非常感谢任何帮助,因为我在我的团队中落后:

var ratemycourse = {};
var App = angular.module('ratemycourse', ['ngResource']);

App.config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/', {
   templateUrl : '/templates/home.html',
   controller : HomeCtrl
 });

 $routeProvider.when('/register', {
  templateUrl : '/templates/register.html',
  controller : RegisterCtrl
  });

  $routeProvider.when('/login', {
   templateUrl : '/templates/login.html',
   controller : LoginCtrl
  });

 $routeProvider.when('/logout', {
   templateUrl : '/templates/logout.html',
   controller : LogoutCtrl
 });

$routeProvider.when('/mcgill', {
templateUrl : '/templates/mcgill.html',
//controller : McGillCtrl
 });

$routeProvider.when('/concordia', {
   templateUrl : '/templates/concordia.html',
   //controller : ConcordiaCtrl
  });

$routeProvider.when('/udem', {
   templateUrl : '/templates/udem.html',
//controller : UdemCtrl
 });
 $routeProvider.otherwise({
  redirectTo : '/'
 });
 }]);

以下是调用 angular.js 代码的代码文件:

<!DOCTYPE html>
    <html lang="en" ng-app="ratemycourse">
      <head>
    <title>Rate My Courses</title>
    <link rel="stylesheet"          href="//cdnjs.cloudflare.com/ajax/libs/foundation/3.2.2/stylesheets/foundation.min.css" />
    <link rel="stylesheet" href="index.css" />
    {{{block "stylesheets"}}}
    <script src="http://www.parsecdn.com/js/parse-1.2.0.min.js"></script>
    <script type="text/javascript">
    Parse.initialize("mWF6nv6fLZx5l0FOYW8SSxfE07fcA4kMHPfl2UzR",       "m2N5pguJAwmEa6pEK1JwQ3nYqCg17K3PXIN3yCKK");
    </script>
  </head>

  <body ng-controller="MainCtrl">
    <nav class="top-bar" ng-controller="HeaderCtrl">
      <ul>

        <li class="toggle-topbar"><a href="/"></a></li>
      </ul>
       <section>
         <ul class="left">

          <li><a href="#mcgill">McGill</a></li>
          <li><a href="#concordia">Concordia</a></li>
          <li><a href="#udem">UDEM</a></li>
        </ul>
         {{email}}
         <ul class="right">
          <li data-ng-hide="isLoggedIn"><a href="#login">Login</a></li>
           <li data-ng-hide="isLoggedIn"><a href="#register">Register</a></li>
          <li data-ng-show="isLoggedIn"><a href="#logout">
            {{email}}</a></li>
          <li data-ng-show="isLoggedIn"><a href="#logout">Logout</a></li>

        </ul>
      </section>
    </nav>

    {{{body}}}

    <script type="text/javascript"   src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript"  src="C:\Users\Usman\Desktop\temp_course_rating\temp_course_rating\public\libs\angular.min.js"></script>
    <script type="text/javascript"  src="C:\Users\Usman\Desktop\temp_course_rating\temp_course_rating\public\libs\angular-    resource.min.js"></script>
    <script type="text/javascript" src="/app.js"></script>
<script type="text/javascript" src="/controller.js"></script>

    {{{block "scripts"}}}
  </body>
</html>
4

1 回答 1

0

src脚本标签的属性应该是 url 而不是文件路径而不是使用 javascipt 源的路径使用 url,如更改

src="C:\Users\Usman\Desktop\temp_course_rating\temp_course_rating\public\libs\angular.min.js">

src="http://localhost/yourproject/angular.min.js">
于 2013-02-10T06:43:16.563 回答