Angular 2 activated route reload component

I have a component that I want to use for different router links and reload it with server data based on the connection parameter. From what I saw at the moment, it is suggested that you get inside the ng zone to cause a re-visualization of the components and their children.

I also pass the object from the http request further to the child components.

This is the onInit code component:

ngOnInit(): void { this.route.params.forEach((params: Params) => { let id = +params['id']; this._userHttpService.getUserData(id) .subscribe(UserData=> this._ngZone.run(() => this.UserData= UserData) ); }); } 

And this is a premium

 <div *ngIf="UserData"> <div class="container-fluid"> <h3>{{UserData.Id}}</h3> <user-tiles [UserData]="UserData"></user-tiles> </div> </div> 

Routes work fine, the correct data is retrieved from the server, and the contents inside <h3> updated after a second, and the custom tile components are not re-displayed. UserData is a built-in user element.

0
angular typescript angular2-routing angular2-components
source share

No one has answered this question yet.

See similar questions:

7
Angular2: How to update converter dependent components?

or similar:

390
@Directive v / s @ Component in Angular
364
How to get the current route
265
In Angular, how do you define the active route?
171
Angular2 - What are the module.id values ​​in a component?
3
Move route route to the same route with a different option in Angular 2
2
How to update a component when it becomes visible in the corner
2
The corner router moves and restarts to display the component once, but displays twice
one
angular 7 routing to the same component, but another parameter does not work
0
Angular6 update request parameters without routing
-one
Angular2 / 4 Get data from another component

All Articles