AngularJS - F5 restarts app

26 views
Skip to first unread message

howard taylor

unread,
Aug 16, 2019, 10:16:35 AM8/16/19
to Angular and AngularJS discussion
AngularJS v1.5.8

I have a fairly simple app that has only two pages - Home page and a page with a ui-grid that displays records.  If you refresh the page through the browser or F5 it seems to restart the App and goes back to the Home page.

I over came that by duplicating the route for the Home page but on the first one in the list I left the "url" attribute an empty string and I changed the "name" atrtibute of the duplicate.

var baseStates = [
    {
        name: 'default_app_home',
        id: 'HomePage',
        display: 'Track Loads',
        url: '',
        templateUrl: '/app/main/modules/home-page/track-loads.html',
        showInMenu: true,
        showOnHomePage: true,
        allowAnonymous: true,
    },
    {
        name: 'HomePage',
        id: 'HomePageReal',
        display: 'Track Loads',
        url: '/modules/trackloads',
        templateUrl: '/app/main/modules/home-page/track-loads.html',
        showInMenu: true,
        showOnHomePage: true,
        allowAnonymous: true,
    }, ................

This works on localhost and from a smart phone once deployed BUT when I Published to the web site the desk top refresh takes the user back to the Home page.

Does any one know what might be causing this and have a remedy?  Thanks.

Sander Elias

unread,
Aug 21, 2019, 1:00:01 AM8/21/19
to Angular and AngularJS discussion
Hi Howard,

An educated guess would be, your server is redirecting to home. Make sure your server serves the index.html for every route and doesn't redirect.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages