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

前端 未结 5 1315
无人共我
无人共我 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:25

    If you need to just display data using an expression like {{mymessage}} inside a div, you don't need a web server.

    But if you need to load template html files uing ngview, you need a web server- otherwise it will complain with following error.

    Request cannot load file. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

    If laoding templates is needed for learning angularjs routing, I found a web server exe easy to use - HFS. So far it meets my requirements for learning AngularJS.

    References

    1. HFS:Introduction
    2. HTTP File Server

提交回复
热议问题