Jason Stone
Aug 8, 2017 · 1 min read

Great article Victor. Thank you.

A tip for those not using html5 mode for routing — you need to be aware that the default prefix in AngularJS v1.6+ is “#!”, but is just “#” (hash) in Angular.
This can cause an infinite loop as each router’s “otherwise” rule kicks in trying to apply their own prefix.
The solution is to set the “APP_BASE_HREF” injectable in Angular to “!”, like so:

import { APP_BASE_HREF } from '@angular/common';@NgModule({
/* ... */
providers: [{provide: APP_BASE_HREF, useValue: '!'}]
})
export class AppModule {/* ... */}

Or to set $locationProvider.hashPrefix('') in your AngularJS application.

EDIT: Also exclude setUpLocationSync(upgrade)when using hashMode.

References:
https://github.com/angular/angular/issues/4155
https://angular.io/api/common/APP_BASE_HREF
https://docs.angularjs.org/api/ng/provider/$locationProvider#hashPrefix

    Jason Stone

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade