4
Hello, I am trying to add an html file inside another page through a directive. And give this error:
Access to Xmlhttprequest at 'file://.../Angularjs/Formul%C3%A1rio%20Simples/views/client.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for Protocol schemes: http, data, Chrome, Chrome-Extension, https.
Directive:
app.directive('myClient', function() {
return {
templateUrl: 'views/client.html'
}; });
Index:
<!DOCTYPE html>
<html lang="pt-br" xml:lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Estudos - AngularJs</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.6/angular.min.js" ></script>
<script src="js/app.js" ></script>
<!--Controllers-->
<script src="js/controllers/Client.js" ></script>
<!--Services-->
<script src="js/services/emails.js" ></script>
<!--Directives-->
<script src="js/directives/client.js" ></script>
</head>
<body ng-app="myApp">
<my-client></my-client>
</body>
</html>
Run your page without being by the two clicks in the file. Otherwise it opens with
file:///
. Try running on a server.– Diego Souza
Apparently it is because of that the problem even, I thought that still would not need server.
– Rafaela Cordeiro