简体   繁体   English

Angular2路由中的问题。 未呈现给孩子的输入

[英]Issues in Angular2 routing. Input to child not rendered

route: /home

    <a routerLink="/dasbhoard"></a>

----------- 

route: /dashboard

<Dashboard>
  <slot  [slotObj]></slot>
  <carousel [carouselObj]></carousel>
</Dashboard>

I work on a project with a structure like the one above. 我从事的项目具有上述结构。 When user clicks on an anchor tag in the home component, he is ui routed to the dashboard component. 当用户单击home组件中的锚标记时,他会被路由到仪表板组件。 I have used the Resolve api to prefetch the objects for the dashboard component and these are in turn sent to the child components within dashboard: slot and carousel 我已使用Resolve api预取仪表板组件的对象,这些对象又被发送到仪表板内的子组件:插槽和转盘

Things work fine with the prefetch and page rendering. 预取和页面渲染可以使一切正常。 However, I notice that the Inputs to the child components on route change are not getting propagated. 但是,我注意到路由更改时子组件的输入没有传播。

Interestingly, if access the dashboard component directly or reload the page after navigation, everything works pretty well. 有趣的是,如果直接访问仪表板组件或在导航后重新加载页面,则一切运行良好。

In short, on ui routing to Dashboard component, the child components do not render properly and no click action could be performed on them, but when the same page is reloaded, all functionalities work well. 简而言之,在ui路由到Dashboard组件时,子组件无法正确呈现,并且无法对其执行单击操作,但是当重新加载同一页面时,所有功能都可以正常工作。

Any help on this would help. 任何对此的帮助都会有所帮助。 I would want to avoid the hard navigation fix. 我想避免硬导航修复。

You should assign some value to input properties as below 您应该为输入属性分配一些值,如下所示

<Dashboard>
  <slot  [slotObj]="slotObjwithValues"></slot>
  <carousel [carouselObj]="carouselObjwithValues"></carousel>
</Dashboard>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM