0
我有一個HTML頁面中的下面的代碼,運行它雖然我不斷收到一個錯誤,指出「角沒有定義」我已經包括在頭角,所以我不知道爲什麼它無法找到它,URL的角度我也能夠直接擊中。html頁無法找到角
<!DOCTYPE>
<html ng-app="test">
<head>
<title>
<script src="https://code.angularjs.org/1.2.25/angular.js"></script>
</title>
</head>
<body ng-controller="TestController">
<form name="CopyFile" ng-submit="copy(fileId)">
<input type="text" ng-model="fileId"/>
<input type="submit" value="Copy"/>
</form>
<div>{{ message }}</div>
<div>{{ error }}</div>
<script type="text/javascript">
(function() {
var app = angular.module("test", []);
var testController = function ($scope, $http) {
$scope.copy = function (fileId) {
$http.get("http://localhost/test/copy/prod.aspx/ToProd?fileId=" + fileId)
.then(onComplete, onError);
};
var onComplete = function (response) {
$scope.message = response;
};
var onError = function (reason) {
$scope.error = "File could not be copied " + reason;
};
};
app.controller("TestController", ["$scope", "$http"], testController);
}());
</script>
</body>
</html>
呃,我不敢相信我沒有看到! – Paritosh
往往很容易忽略明顯的:) –
您在控制器方法定義中也有一個錯字。右括號']'不正確。它應該是'app.controller(「TestController」,[「$ scope」,「$ http」,testController]);' – AWolf