router icon indicating copy to clipboard operation
router copied to clipboard

There should be a non-static `go` method

Open Artur- opened this issue 7 years ago • 4 comments

When you navigate to another view by looking up the URL, you need to have the router instance. To be able to navigate to another view, you need to have the Router class. So unless I misunderstand something you cannot do

import { router } from './my-app.js';
...
router.go(router.urlForName('users-view'));

but instead you must do

import { router } from './my-app.js';
import { Router } from '@vaadin/router';
...
Router.go(router.urlForName('users-view'));

Artur- avatar Oct 30 '18 13:10 Artur-

Workaround: router.constructor.go(router.urlForName('users-view'));

vlukashov avatar Oct 30 '18 13:10 vlukashov

Any update on this?

piotrekwitkowski avatar Mar 16 '19 23:03 piotrekwitkowski

Agree!

abdonrd avatar Jul 31 '19 09:07 abdonrd

+1

aress31 avatar Jul 10 '20 06:07 aress31