Skip to main content
Pergunta fechada como "Não é adequada para este site" por Largato
Tweeted twitter.com/StackOverflowPT/status/1249714037983764480
título editado
Link

Erro ao criar diretiva AngularJs: Access to XMLHttpRequest at 'file:///...' from origin 'null' has been blocked by CORS policy

Fonte Link

Erro ao criar diretiva AngularJs

Olá, estou tentando adicionar um arquivo html dentro de outra página atraves de uma diretiva. E da este erro:

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.

Diretiva:

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>