Angular5, on routing, url changes but it doesnt load the same page

developer

On click next, URL is getting change but the page, as per url doesn't load. when I click next, url changes and if I refresh the page using same url then it loads the correct page. Below is my ts and html code.

on ts

  ngOnInit() {
    const queryParams = this.route.snapshot.queryParams; // store query param value
    this.index = queryParams.index;
    this.step = queryParams.step;
    this.flowType = queryParams.flowType;
    this.stepper.selectedIndex = Number(this.step);
    console.log(this.index, "this.index", this.step, "this.step",  this.flowType, " this.flowType");
  }

on HTML

<div *ngIf="flowType === 'Prescription Drug Plan'">
  <app-form-navigation   (customHandle)="setApplicationQualification()" isQueryParamPreserve='true'
    nextPath="enrollments/steps/find-a-drug" [queryParams]='{index:2, step:0}' >
  </app-form-navigation>
</div>
tano

Angular won't reload the same component if you don't navigate away from it. you should use something similar:

constructor(protected route: ActivatedRoute){
}
ngOnInit(){
    this.route.queryParams.subscribe(params => this._init(params));
}
_init(queryParams){
    this.index = queryParams.index;
    this.step = queryParams.step;
    this.flowType = queryParams.flowType;
    this.stepper.selectedIndex = Number(this.step);
    console.log(this.index, "this.index", this.step, "this.step",  this.flowType, " this.flowType");

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular Routing changes the page

Ionic 4 routing not working the url changes but view doesnt appear

how to refresh page when routing url changes in angular

Angular Routing: Url changes but always shows home page component

url change but still on the same page with routing angular 4?

Angular2 Hashtag routing to Anchor doesnt move page

How to disable url changes with Angular routing

Angular 5 - Routing changes url but doesn't navigate

Django serve Angular throws empty page and doesnt load static files

Redirect in the same page doesnt work?

Angular5: Spinner is not working perfectly on page load

Angular5: loading spinner before load page

Angular 5 - Routing to the same component with different URL's

Angular routing issue - url updating but not page

Angular change URL on page load

Load another url into a html page using Jquery loads the same page

.openDialog() method doesnt load page in TFS 2017

Prevent routing in Angular when user manually changes url in browser tab

Angular 14: App not routing even though path changes in the URL

Angular 5 routing issue in a feature module (force router to reload route when path is same but param changes)

Angular5 reverse routing

React doesnt load image from url

Angular doesnt destroy source component after routing

Cannot load files when paste URL manually Angular 2 routing?

Use Apache to load a page sitting on a different server with the same URL

Load another page on the same tab, Maintain the previous url on the address bar

How to detect routing to same page in Angular2?

ASP.NET MVC routing: 2 route for same page, how to give same url rendered?

routing with hbs displaying the same page

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive