AngularJS Offline application using AngularJS

76 views
Skip to first unread message

Prayag Ganoje

unread,
Jul 16, 2017, 5:55:57 PM7/16/17
to Angular and AngularJS discussion, prayag ganoje
HI,

I am experiencing one issue in offline mode application using AngularJS. Used CACHE MANIFEST to cache all the Templates, css and js Files in application cache. example

While running the application very first time after deployment to IIS server, even though all the templates/files are cached, route controller tries to get that template from network and not from cache.

On the contrary, if I access all the templates in the application once then next time onwards route controller always loads templates from cache. (tested this feature by disconnecting internet)  

My expectation is once all the templates are loaded in cache then why do I need to access each html template once very first time after application is deployed to IIS.

I guess I can explained this issue. Please suggest how to fix it ? or am I missing anything.


Sander Elias

unread,
Jul 16, 2017, 11:18:29 PM7/16/17
to Angular and AngularJS discussion, prayag...@gmail.com
Hi Prayag,

There are quite a few tools out there that let you grab your templates and compile them to JS, is there an reason you are not using one of those? This would give you much better control on this.


Regards
Sander






prayag ganoje

unread,
Jul 17, 2017, 2:29:29 PM7/17/17
to Sander Elias, Angular and AngularJS discussion
Thanks for the reply. Following additional code fixed the issue.

app.controller('defaultController', function ($scope, $templateCache, $http) {
    console.log($templateCache.info());
    $http.get("templates/About.html", {
        cache: true
    }).then(function (resp) {
        //console.log(resp.data);
        $templateCache.put("templates/About.html", resp.data)
    });
});

Sander Elias

unread,
Jul 18, 2017, 5:49:15 AM7/18/17
to Angular and AngularJS discussion, sande...@gmail.com
That will work too. For myself, I prefer to do as much as possible during build.
Reply all
Reply to author
Forward
0 new messages