Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a component from history in angular 2

How could i restrict a component to load on back press. Actually i have three component A(Normal Component), B(LoginComponent) and C(Otp Verification Component). I'm routing to component B from A on some button click and from B to C to verify user. now after verification done on component C, i want to go back on component 'A', and want to remove component 'B' and 'C' from history so that on back press from browser it does not load 'B'(LoginComponent) and 'C' again. so how could i do this in angularjs 2.

like image 367
Ravi Sevta Avatar asked Nov 18 '16 18:11

Ravi Sevta


1 Answers

While navigating from components B and C, pass the option replaceUrl:true to replace B with C in the browser history.

Eg:

//Navigating to state C 
this.router.navigate(["/C"], { replaceUrl: true });

Checkout the documentation for replaceUrl

like image 91
Vandesh Avatar answered Nov 02 '22 03:11

Vandesh