October 2017
Intermediate to advanced
280 pages
6h 50m
English
The PathLocationStrategy class uses APP_BASE_HREF, which, by default, has the "/" string as a value. This means that, in case the base pathname of our application is different, we must set it explicitly in order to have a properly functioning routing. For instance, in our case, the configuration should look as follows:
import {APP_BASE_HREF} from '@angular/common';
//...
@NgModule({
...
providers: [{
provide: APP_BASE_HREF,
useValue: '/dist/dev/ch7/multi-page-template-driven/'
},
{ provide: LocationStrategy, useClass: HashLocationStrategy }
]
})
class AppModule {}
Here, APP_BASE_HREF represents the base path of the application. For instance, in our case, the "Coders repository" will be located under the /dist/dev/ch7/multi-page-template-driven/ ...
Read now
Unlock full access