2016-12-29 65 views
1

后的URL我有一对夫妇的路线是这样的...为什么角2路由器更新模板,但没有手动更改

[ 
    { 
     path: "admin", 
     component: ContentComponent, 
     canActivate: [ CanActivateIfAuthenticated ], 
     children: [ 
      { 
       path: "", 
       pathMatch: "full", 
       redirectTo: "tenants", 
      }, 
      { 
       path: "tenants" 
       component: TenantComponent 
      } 
     ] 
    } 
] 
[ 
    { 
     path: "other", 
     component: ContentComponent, 
     canActivate: [ CanActivateIfAuthenticated ], 
     children: [ 
      { 
       path: "", 
       pathMatch: "full", 
       redirectTo: "item", 
      }, 
      { 
       path: "item" 
       component: ItemComponent 
      } 
     ] 
    } 
] 

当我在/admin/tenants和我手动更改URL,该routerOutlet更改但url仍然/admin/tenants。但是,当我将其更改回/admin时,它会转到admin/tenants屏幕,但网址显示为/other/item。 Router.navigateByUrl似乎没有相同的问题。我正在使用HashLocationStrategy,我有一个基本标记集,所以我不认为这是问题。

这里有一个更新:

我已经跟踪它到这段代码在路由器...

if (navigationIsSuccessful) { _this.routerEvents.next(new NavigationEnd(id, _this.serializeUrl(url), _this.serializeUrl(_this.currentUrlTree))); resolvePromise(true); } else { _this.resetUrlToCurrentUrlTree(); _this.routerEvents.next(new NavigationCancel(id, _this.serializeUrl(url), '')); resolvePromise(false); }

navigationIsSuccessful解析为假,所以它被调用重置网址功能。然后另一个(正确的)通过,但url已被重置。如果我看哪里不好请求从在的调用堆栈的东西条款来得到怪异还是因为调用堆栈建议此行引起了runNavigate ...

notifications = new Subject(); ... this.notifications.next({ isAuthenticated : exp, message: message, });

似乎喜欢的事,不应该导致导航。

+0

“我手动更改网址” - 为什么值? –

+0

根据描述,如果我在/ admin /租户路线上,我会将其更改为/ other。如果我在/ other/item路径上,它将是/ admin。我有更多的路线,但只是试图简化它在这里。道德是在栏中显示的网址恢复到以前的网址。一旦我点击回车导航,我就会看到它“快照”。 – Jackie

+0

另外应该注意的是,这些都是在他们自己的路由模块中,并导入到一个通用路由模块(最终由我的主模块导入) – Jackie

回答

1

我不得不从路由器v 3.3.0升级到v 3.4.1

相关问题