Skip to main content

Posts

Showing posts with the label APP_BASE_HREF

What Is APP_BASE_HREF in Angular 4/5?

The APP_BASE_HREF token represents the base “ href ” to be used with the PathLocationStrategy . The APP_BASE_HREF token is available when using JIT runtime and APP_BASE_HREF token represents the base “ href ” and it’s used with the PathLocationStrategy . If you are using the PathLocationStrategy that means you must provide a provider to a string representing the URL prefix. The URLs prefixes are strictly local in Angular Apps and router navigates to the new component and renders its template and also updates the history and URL for the view. These all happens in the browser locally. Angular supports two Location Strategies and its looks like - ü   When you are using HashLocationStrategy that means the URL looks like-“ http://localhost:9099/#/user ” ü   When you are using PathLocationStrategy that means the URL looks like-“ http://localhost:9099/use r” Example – Using the APP_BASE_HREF token import { Component , NgModule } from '@angular/core' ...