0
你好,我是新的Java腳本。我的小組成員已經爲項目創建網站編寫了一些代碼,並且我想在我的筆記本電腦上運行它。我們在客戶端使用AngularJS。但我收到以下錯誤:JavaScript:使用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>
hello sudhir, 我使用以下鏈接下載angular.min.js文件,因此我必須將其保存在本地目錄中。我怎樣才能得到的網址? http://angularjs.org/ – ueg1990 2013-02-10 07:02:35
複製項目文件夾中的angularjs文件,並使用如下所示的URL:http://localhost/your_project/your_angular_jsfolder/angular.min.js – 2013-02-10 07:04:19
閱讀教程:: http:// docs .angularjs.org /教程一步一步 – 2013-02-10 07:05:26