Does Angular need a web server to run? So would Angular work if I give browser a url of a local file?

前端 未结 5 1257
无人共我
无人共我 2021-02-12 10:55

By this I mean I have read that Angular allows mock up data to be used so that RESTFul apis need not be wired up. I can think of a use case where a UX designer need only look a

5条回答
  •  甜味超标
    2021-02-12 11:20

    Yes you can run a local file, but if you need data off a server, the browser should block it, depending on what version and type of browser you are running.

    Here is the official Angularjs Tutorial explanation under the PhoneCat Tutorial App: Running the Development Web Server

    While Angular applications are purely client-side code, and it is possible to open them in a web browser directly from the file system, it is better to serve them from an HTTP web server. In particular, for security reasons, most modern browsers will not allow JavaScript to make server requests if the page is loaded directly from the file system.

提交回复
热议问题