angulardart / angular

Fast and productive web framework provided by Dart
https://pub.dev/packages/angular
MIT License
1.83k stars 232 forks source link

I can't navigate directly to a parent route #1881

Open insinfo opened 4 years ago

insinfo commented 4 years ago

I can't navigate directly to a parent route like the one below: "http://127.0.0.1:8080/#/home/lives" I can only navigate to the "/lives" page if I first navigate to "/home" I have two areas in the app one is a public area and the other is an area that is only accessible via authentication, so I have two router-outlets

if I navigate straight to "/home /lives" everything is blank

home_component.html

image

home_component.html ```html
```
route_paths.dart ```dart class RoutePaths { static final lives = RoutePath(path: 'lives', parent: PublicRoutePaths.home); static final liveEdit = RoutePath(path: '${lives.path}/edit/:id', parent: PublicRoutePaths.home); static final liveNew = RoutePath(path: '${lives.path}/new', parent: PublicRoutePaths.home); } class PublicRoutePaths { //public routes static final livePublic = RoutePath(path: 'livePublic'); static final home = RoutePath(path: 'home'); } ```

image

routes.dart ```dart static final lives = RouteDefinition( routePath: RoutePaths.lives, component: live_list_template.LiveListComponentNgFactory, ); static final liveEdit = RouteDefinition( routePath: RoutePaths.liveEdit, component: live_form_template.LiveFormComponentNgFactory, ); static final liveNew = RouteDefinition( routePath: RoutePaths.liveNew, component: live_form_template.LiveFormComponentNgFactory, ); static final all = [ lives, liveNew, liveEdit ]; } class PublicRoutes { static final home = RouteDefinition( routePath: PublicRoutePaths.home, component: home_template.HomeComponentNgFactory, useAsDefault: true); static final livePublic = RouteDefinition( routePath: PublicRoutePaths.livePublic, component: live_public_template.LivePublicComponentNgFactory, ); static final all = [ home, livePublic, ]; } ```
app_component.html ```html ``` home_component.html ```html ``` =2.4.0 <3.0.0' dependencies: angular: ^5.3.1 angular_components: ^0.13.0+1 angular_forms: angular_router: ^2.0.0-alpha+19 http: ^0.12.0+2 stream_transform: ^0.0.19 sass_builder: ^2.1.3 firebase: ^5.0.2 firebase_dart_ui: ^0.1.2 js: ^0.6.1+1 spreadsheet_decoder: ^1.1.0 queries: ^0.1.12 essential_components: ^0.1.75 dev_dependencies: angular_test: ^2.3.0 build_runner: ^1.7.2 build_test: ^0.10.9+1 build_web_compilers: ^2.7.1 pedantic: ^1.8.0 test: ^1.6.0 ```
ganigeorgiev commented 4 years ago

I'm not sure whether is the same, but you could check https://github.com/dart-lang/angular/issues/1314.

I had similar issue when all my nested route paths were using RoutePath.parent but as @leonsenft commented, RouteDefinition.routePath doesn't traverse parent references and only the path property is actually taken in consideration in this case.

insinfo commented 4 years ago

@ganigeorgiev I believe it is not the same thing

I need in my application, to have public routes with components in full screen and private routes that are navigable in a view similar to tabs, as can be seen in the image I posted, it is working, but I can't access it directly by typing the URL in browser.

I can do this very easily with Slim Framework Route with Twig template render, but in AngularDart this is not working as expected

afpatmin commented 4 years ago

@insinfo Are you getting a console error that says Uncaught SyntaxError: Unexpected token <? In that case it is probably related to https://github.com/dart-lang/sdk/issues/29247

insinfo commented 4 years ago

I don't get any error, the screen goes white

insinfo commented 4 years ago

I can use the application normally, as long as I navigate to the home page first, the problem only occurs if I try to navigate directly to "#/home/live" which is frustrating

afpatmin commented 4 years ago

Could it be that the home-component just isn't avaiable at page load? For example if you wrap it in an *ngIf="some future bool"?

insinfo commented 4 years ago

I believe that this is not the problem

afpatmin commented 4 years ago

Would you mind sharing the contents of app_component.html?