我剛剛從視頻教程中學習了angularjs的打字稿。當我嘗試將角度模塊放在我的「app.ts」文件中,該文件默認是後端的主文件。這裏是我的app.js代碼:當我使用打字稿時,我得到「Uncaught ReferenceError:angular is not defined」
/// <reference path="Scripts/typings/jquery/jquery.d.ts" />
/// <reference path="Scripts/typings/angularjs/angular.d.ts" />
console.log("This is a TS file");
angular.module('classProjectApp', ['ngRoute'])
.config(function ($routeProvider) {
console.log("in Config()");
});
我在index.html文件出外添加angularjs文件:
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TypeScript HTML App</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script src="app.js"></script>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-route.min.js"></script>
</head>
<body>
<h1>TypeScript HTML App</h1>
<div id="content"></div>
</body>
</html>
儘管這樣,我得到一個錯誤
Uncaught ReferenceError: angular is not defined
雖然視頻教程中的相同示例正常工作。
P.S.當在index.html文件中爲角度添加引用時,我必須在視頻教程示例中使用「angular.js」引用相對路徑(Scripts /.../.../angle.js)。
謝謝。
''爲angularjs' script'標籤應該先走了。 – Pengyy
''shoud go below –
你想做什麼? Angular 1還是Angular 2?爲什麼.ts文件進入圖片? –