E
E
Eugene2017-08-25 20:08:00
Angular
Eugene, 2017-08-25 20:08:00

How to pass the name of an element when navigating to its view component?

Has a list view component. Navigation to view the element is implemented by passing the Id in the link.

<td><a [routerLink]="['/item', item.id]" >{{item.name}}</a></td>

When initializing the element view component, the Id parameter is read, a request is made, and then the data on the element is displayed.
The point is that the view component has a dynamic title, which is formed from the item.name property . How to actually pass this name so that there is no delay in displaying the title, while additional information on the element is loaded asynchronously?
There is an idea to make routing like [/item/name-id] => get the name from the address and display it immediately. Is there some least "crutch" way?
p/s Angular 4

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
furrya_black, 2017-08-28
@furrya_black

I keep pagetitles in a state, there are a couple of actions, setShortTitle, setLongTitle, each pull of these actions updates document.title.
https://bitbucket.org/furrya_black/cake-shop

O
ozknemoy, 2017-08-27
@ozknemoy

the first version of the resolve in the router and already in the new page is transferred from the back. the second is worse via queryParams: add [queryParams]="{name: item.name}" to the link, but Cyrillic in the url is not ice IMHO

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question