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