簡體   English   中英

在nebular ui nbwindow中從子組件獲取數據到父組件

[英]Get data from child component to parent component in nebular ui nbwindow

我有兩個組件,一個是父組件,另一個是子組件(沒有選擇器)。 我正在使用 Nebular ui 創建一個 window (使用nbWindowService.open(ChildComponent) 。子組件中有一個表單,我需要將該數據取回父組件進行處理。

在 angular 材料對話框中,我會執行類似this.dialogref.close(data)的操作。 Nebular ui 沒有這種靈活性。 如何將數據發送回父組件? 請記住,子組件不是父組件的直接子組件,並且它沒有選擇器。

對於對話框dialogService.open返回onClose可觀察的,您可以在其中訂閱

我認為對於 window 一些基本的 stream 服務是首選

    @Injectable()
    export class WindowResultService {
      private stream = new BehaviorSubject<IWindowResult>(undefined);
      public get(): Observable<IWindowResult> {
        return this.stream;
      }
      public next(data: IWindowResult) {
        this.stream.next(data);
      }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM