Angular 2/4 not work correctly in first load

时间:2017-06-09 12:53:36

标签: angular angular2-routing

I have error when using router.navigate in angular 4, when route to other page, this page is not load correctly after refresh page.

I'm using angular2-color-picker

First time load page, color box is just text. First time load page

And after refresh, it had background color. enter image description here

Any help is appreciate.

1 个答案:

答案 0 :(得分:0)

添加到提供商的app.module

import { LocationStrategy, HashLocationStrategy } from  '@angular/common';


@NgModule({  
 ...
 providers: [ 
 {
  provide: LocationStrategy,
  useClass: HashLocationStrategy
 }]
})
export class AppModule {
}