uzhas
uzhas

Reputation: 925

How to use hashbang?

I want to use hash in angular routes. I tried to find but all examples are for oldest version. Any suggestion how can i do that?

I tried this:

let injector = ReflectiveInjector.resolveAndCreate(NgModule);
let http = injector.get(Http);
let authService = new AuthService(new LocalStorage(), http);

  providers: [ {provide:AuthService,useValue:authService}, // over here 
    SharedService,DatePipe],

But im getting error:

Can not find local storage, can not find AuthService and i can not use NgModule in ReflectiveIncjector.

Any suggestion how can i use hashbang?

Upvotes: 0

Views: 3430

Answers (1)

eko
eko

Reputation: 40647

In your @NgModule you use useHash:true:

imports: [
     RouterModule.forRoot([
       ...
      ]
      ,{ useHash: true }
  )],

Source: https://angular.io/docs/ts/latest/guide/router.html#!#-hashlocationstrategy-

Upvotes: 7

Related Questions