Angular 角度2/4在第一次加载时不能正常工作
我在使用router.navigate时出错。在angular 4中导航,当路由到其他页面时,刷新页面后无法正确加载此页面 我正在使用angular2颜色选择器 第一次加载页面时,颜色框只是文本。 刷新后,它有了背景色。 任何帮助都将不胜感激Angular 角度2/4在第一次加载时不能正常工作,angular,angular2-routing,Angular,Angular2 Routing,我在使用router.navigate时出错。在angular 4中导航,当路由到其他页面时,刷新页面后无法正确加载此页面 我正在使用angular2颜色选择器 第一次加载页面时,颜色框只是文本。 刷新后,它有了背景色。 任何帮助都将不胜感激 添加到提供商中的app.module import { LocationStrategy, HashLocationStrategy } from '@angular/common'; @NgModule({ ... providers:
添加到提供商中的app.module
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
@NgModule({
...
providers: [
{
provide: LocationStrategy,
useClass: HashLocationStrategy
}]
})
export class AppModule {
}
添加更多代码或创建plunker。没有代码就很难理解问题,因为必须使用哈希策略。在您的模块中,执行以下操作:
RouterModule.forRoot(您的路由,{useHash:true})
@trichetriche我已经在app.routing.ts中添加了这个,但不工作导出常量routing:ModuleWithProviders=RouterModule.forRoot(路由,{useHash:true});