Makes Angular JS works offline
angularjs, html, javascript
Solution
To make your application work offline, you have to cache every file with the html5 cache manifest. Even the .html files, images, css, everything...
The native "old" caching won't work here, because it still requires to communicate with the server to have the "304 Not Modified" http code.
The manifest removes this step and doesn't even ask the server for the resources.
An example manifest:
CACHE MANIFEST
/angular.js
/index.html
/page/home.html
/page/profile.html
NETWORK:
*
How to include and use cache manifest check: http://www.w3schools.com/html/html5_app_cache.asp
For debugging:
Clearing a app cache under chrome enter url "chrome://appcache-internals/"
EDIT: Due to comment and off the topic
Instead of placing the html code in many own html files, you can include them in index.html like this:
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
Then your `templateURL` is "one.html" without subpath.
Check docs: https://docs.angularjs.org/api/ng/directive/script
Hint:
You dont need to place any paths there. During rendering phase, angularjs will store every html file in the `$templateCache` under it's `id` placed in those script elements.
Problem
I am developing a single page application, with help of AngularJS and I'm new to it I asked the same question before but haven't got any answer so I am rephrasing my question and ask it again THE QUESTION: What I need to do is to make my web app enabled to work offline for this purpose the html files which are rendered as view (for example home.html) should be included somehow in the index.html, So when clicking on the some links there should be no need to have access to a html file instead a part of the same page for example a dive will be rendered, what modifications should I make to project to get this done at the moment I made different html files and use them as templates when rendering views, the structure of app is like this : ``` - index.html - pages ----- home.html ----- profile.html ``` here is the code for config the routes and controllers and views ``` var formApp = angular.module('formApp', ['ngRoute']); formApp.config(function($routeProvider) { $routeProvider .when('/', { templateUrl : 'main', controller : 'mainController' }) .when('/profile', { templateUrl : 'profile', controller : 'profileController' }) }); ``` And and my main.html file for example is like this : ``` <div class="jumbotron text-center"> <h1>Main Page</h1> <p>{{ message }}</p> </div> ``` َand somewhere in the index.html I have ``` <div ng-view> {{ message }} </div> ``` The code works properly and everything is fine at the moment