Use Angular routes straight from HTML file

Asked

Viewed 248 times

6

I need to develop an offline app where it will be accessed directly from the HTML file, as far as I know Angular needs the HTTP protocol to perform the routes yet.

Ex.: The URL will look like this file://angular-project/index.html/#/lista instead of http://localhost/angular-project/#/lista

I need it to work with the file://

1 answer

2

Your offline application can make use of Application Cache.

Basically, you will need to create a file manifest containing a mention to all the files you want to offer in offline mode.

When prompted, the browser will first try to load the files from Application cache, only then try to establish an HTTP connection to the server.

(If new versions of at least one of the files is available, you can then try to reload the application.)

This mechanism is compatible with Routes and States angularjs.

References for consultation:

http://www.w3c.br/cursos/html5/conteudo/capitulo22.html
http://diveintohtml5.com.br/offline.html

  • Yes with Application Cache works, but the problem is that the user will not access the application over the internet it will be distributed from the USB stick, so it will not have HTTP connection, will be accessed directly from the HTML file

  • 1

    I wouldn’t recommend this template for two reasons: Under various circumstances browsers consider local content to be 'unsafe', forcing you to download the security requirements for your code to run. Second, the resolution of permissions and partial names occurs differently in different browsers. Tip: Distribute with a portable web service such as Z-WAMP (http://zwamp.sourceforge.net/).

Browser other questions tagged

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