digiwand
digiwand

Reputation: 1348

Should I migrate from ngRoute to ui-router?

I have a pretty extensive ngRoute router right now with around 15 different URL paths. The website I am working on displays pages with heavy data, lots of charts, etc. for a logged in user. My issue is that when I refresh the page, it will redirect me to my default page. I have tried adding these:

app.config

    if(window.history && window.history.pushState){
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });
    }

< head> tag

<base href="/"/>

.htaccess

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) index.html [L]
</ifModule>

This didn't work for me. It seems that switching to ui-router fixed this same issue for this guy in this link: AngularJS Route breaks on manual refresh

My questions:

  1. Will ui-router really handle the manual refresh properly?
  2. Is it worth it to migrate from ngRoute to ui-router or is it better to find the solution to manually refresh properly with ngRoute?

Upvotes: 1

Views: 227

Answers (1)

digiwand
digiwand

Reputation: 1348

I made the move, the migration was smooth, and it fixed my refresh issue! Feeling good about the switch.

Upvotes: 2

Related Questions