简体   繁体   中英

html page can not find angular

I have the below code in a html page, running it though I keep getting an error stating that "angular is not defined" I have included angular in the head so i'm not sure why it can't locate it, the url to angular i'm also able to hit directly.

 <!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> 

This may not be the cause but you don't want your angular include inside of your title. It should be something more like this:

<!DOCTYPE>
<html ng-app="test">
<head>
    <title>My Page</title>
    <script src="https://code.angularjs.org/1.2.25/angular.js"></script>
</head>
.....

You gave <script> inside <title> ?

<title>
    <script src="https://code.angularjs.org/1.2.25/angular.js"></script>
</title>

Please remove it outside.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM