简体   繁体   English

Angular 2显示相同的组件,而其他组件中的数据相同

[英]Angular 2 show same component with same data in other component

Its more design question. 它更多的设计问题。

As an example I have a page that display the data, and I have a button that opens up the modal. 例如,我有一个显示数据的页面,还有一个打开模式的按钮。 Need to show exact same page inside the modal, and this modal is an external component. 需要在模式内部显示完全相同的页面,并且该模式是外部组件。

More detail: I have a main component, inside which I have another component that receives some data from it via @Input decorator. 详细信息:我有一个主要组件,在里面有另一个组件,该组件通过@Input装饰器从中接收一些数据。 When I view the page "main-component" it shows all data as expected from message-preview. 当我查看页面“主要组件”时,它显示了所有来自消息预览的数据。 However I created a separate modal component which is child message-preview component, which is triggered through the button inside . 但是,我创建了一个单独的模态组件,它是子消息预览组件,它是通过中的按钮触发的。 Ho

How can I duplicate (clone) exact same page as in in modal component without passing data again as its already there? 如何复制(克隆)与模态组件中的页面完全相同的页面,而又不传递数据,因为它已经在那里?

  <main-component>
     <app-message-preview [message]="selectedItem" [context]="context">
     </app-message-preview>
  </main-component>

External componenet 外部组件

<modal-component>
        <app-message-preview [message]="selectedItem" [context]="context">
         </app-message-preview>
</modal-component>

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

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