Skip to main content

Posts

Showing posts with the label HashLocationStrategy

What Is HashLocationStrategy?

What Is HashLocationStrategy? To enable HashLocationStrategy in an Angular app you pass {useHash: true} when you providing routes with router module and it like this.    //Composability and Grouping    //imports used for composing modules together.    imports:  [      BrowserModule ,      //enableTracing enables debugging purposes only      //useHash enables the location strategy that uses the URL fragment instead of the history API.      RouterModule . forRoot ( appRoots , {  enableTracing:   true ,  useHash: true  })    ], The HashLocationStrategy add the route path to the hash (#) in the browser’s URL. The hash (#) part of the URL is called the hash fragment. When using HashLocationStrategy for routing and providing a base Href, it always placed after the hash (#) e.g. http://localhost:8080/#/UserDetail/1...

What Is PathLocationStrategy?

A LocationStrategy used to configure the Location service that represents its state in the path of the browser's URL and the PathLocationStrategy is a default routing strategy. When you are using the PathLocationStrategy, we must provide  APP_BASE_HREF  in the module or base element in the app document. For more detail kindly refer the link - https://www.code-sample.com/2018/05/angular-5-6-7-routing-and-navigation.html