0
votes

app.component.ts

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers:
[BureauApiService,BureauStateWorkflowComponent,CommondataApiService]

})
export class AppComponent implements OnInit {
constructor(
private router: Router,
private bureau:BureauStateWorkflowComponent,
private _location: Location,
) { }
ngOnInit(){
 //this.bureau.getPosts();
 this.router.navigate(['/']);
 localStorage.clear();
 }
 }

In localhost this router navigate is works correctly when browser refreshing.it navigate to home page but after deploying in iis it not work. Return this type error page. HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

1

1 Answers

0
votes

finally I found the answer.I used LocationStrategy and HashLocationStrategy to providers section in app.module.ts class and change the app.component.ts class as below

In app.module.ts

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

@NgModule({
providers: [Configurations, BureauApiService, CreditorApiService,{provide: 
LocationStrategy, useClass: HashLocationStrategy},FlashMessagesModule],
})
export class AppModule { }

In app.component.ts

ngOnInit(){
//this.bureau.getPosts();
this.router.navigate(['/#']);
localStorage.clear();
}

It works properly