Requisition Angularjs

Asked

Viewed 101 times

1

I’m starting with Angularjs and to study I created an application I saw on the internet, but when I use the command
"ng-include="'Footer.html'" inside the div it gives an error in the console.

angular.js:12578 Xmlhttprequest cannot load file:File Path. Cross origin requests are only supported for Protocol schemes: http, data, Chrome, Chrome-Extension, https.

I already changed the permissions of the folder so that everything had access and it still didn’t work.

1 answer

2

You are probably opening the html file directly from a folder, using the protocol file://, and Chrome does not allow the use of Xmlhttprequest for Urls of this type, so the error.

What you need is to use some http server, there are several simple to use, if you are using some IDE to develop it may already have some support, if you want to use some programming language for the backend might be worth using his to do this, for example Iisexpress if using ASP.Net or LAMP/WANP if using PHP.

  • Leonardo, I don’t know anything angular, if I create an application in . net mvc I can work it the same way is that ?

  • Angular is used for Frontend, usually you will need some other language for Backend, it is quite common to use the ASP.Net Webapi for this and nothing prevents you from having both in the same project to take advantage of Iisexpress to be able to test your program.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.