Routing: get notified about parameter updates with

2019-08-10 22:19发布

问题:

This is my first attempt with routing in Angular but it works so far
(suggestions for improvement are welcome)

  call(Router router, ViewFactory views) {
    router.root
    ..addRoute(
        name: 'form',
        path: '/:entityId/form/:recId',
        enter: views('view/dynamic_form.html')
        )
    ..addRoute(
        name: 'table',
        path: '/:entityId/table/:recId',
        enter: views('view/dynamic_table.html')
        )
    ..addRoute(
        name: 'default_view',
        defaultRoute: true,
        enter: (_) =>
            router.go('form',
                {
                  'entityId': '',
                  'rec': '-1'
                },
                replace: true));

This works fine so far, but when i click a link that changes only the recId but stays in the same view (e.g. view/dynamic_form.html) the view gets still reloaded which results in an annoying (very brief though) disappear/appear of the view.

Is it possible to get notified about parameter updates without reloading the view?

回答1:

It is one of the use-cases on the TODO list: https://github.com/angular/route.dart/issues/1