F
F
Fires2017-05-16 00:35:57
Angular
Fires, 2017-05-16 00:35:57

How to implement a transition inside the same component in angular2?

There is a Profile component - a user card. The request for user information lies in ngOnInit(), i.e. called only when the ngOnInit() function from the OnInit interface fires.
Problem:
We are on the card of one of the users. This card has links to the cards of two other users: /profile1 and /profile2. When you click on any of them, the url changes, but requests from ngOnInit() do not occur.
How to be?
Tried other lifecycle interfaces, but only ..Changes works. And they work for every sneeze, which is completely unnecessary.
Now a crutch is screwed on: by clicking on the user's link, manually call the data update function on the card. This solves the problem, but only if we are in the Profile component, from other components such a crutch turns into a giant SuperMegaCrutch.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-05-16
@Fires

Whether so you can check with in onChange the user changed. If so, then run init again, just transfer the data to the new method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question