Javascript 从角坐标系中的主子元件更新父元件中的布尔属性

Javascript 从角坐标系中的主子元件更新父元件中的布尔属性,javascript,angular,angular6,Javascript,Angular,Angular6,我有一个Grand Parent组件,其中有一个按钮,根据一些代码,我想显示/隐藏该按钮,因此我的代码如下: grandparent.component.html <button mat-raised-button title="Send RFP to Suppliers" (click)="RequestForBid()" *ngIf="Is

我有一个Grand Parent组件,其中有一个按钮,根据一些代码,我想显示/隐藏该按钮,因此我的代码如下:

grandparent.component.html

 <button
            mat-raised-button
            title="Send RFP to Suppliers"
            (click)="RequestForBid()"
            *ngIf="IsAllSuppliersGetRFP"           
 >
方法设置结束按钮如下:

     SetSendButton() {
    let all_supplier_request_recived=true;
    this.quoteDTO.lineitems.forEach(x=>{
      x.item_quantity.forEach(y=>{
         y.quote_lineitem_rfp.forEach(z=>{
           z.rfp_suppliers.forEach(a=>{
              if(!a.is_request_for_bid)
               {
                all_supplier_request_recived=a.is_request_for_bid;                
               }
           })
         })
      })
    });
    return all_supplier_request_recived;
  }
现在我有了另一个子组件,在子组件中我有了另一个大的子组件,该组件作为父框上的弹出窗口打开。在弹出窗口关闭时,我想将Grand Parent字段
IsAllSuppliersGetRFP
设置为true

我不知道我怎样才能把那笔财产从祖父母那里拿到孙儿那里,然后把它设置好。我知道输入和输出,但因为这是孙子孙女,所以我不想在孙子孙女之间传递

我也阅读了有关服务的信息,以便在多个组件之间传递值,但我不确定如何才能在服务类中获得
this.quoteDTO

我还阅读了有关服务的信息,以便在多个服务之间传递值 组成部分

是的,你可以用下面的方法

在共享服务中添加主题变量

public quoteSubject: Subject<any> = null;

public notifyWithType(type: string, message: any = null) {
   this.quoteSubject.next({ type: type, text: message });
}
添加一个方法来绑定服务主体,以便在触发事件时接收值

ngOnInit() {
  this.sharedService.quoteSubject.subscribe(result => {
      if (result.type === 'all_suppliers_getRFP') {
        this.setAllSuppliers(result.text);
      }
  });
}

setAllSuppliers(value: any) {
   // sent object (DTO or boolean)
   this.quoteDTO = value;
   this.IsAllSuppliersGetRFP = // 'value from DTO' as boolean;
}
您可能需要在这里更改一些内容,因为我无法准确理解您的要求

快乐编码…)

this.sharedService.notifyWithType("all_suppliers_getRFP", 'boolean value' or 'DTO');
ngOnInit() {
  this.sharedService.quoteSubject.subscribe(result => {
      if (result.type === 'all_suppliers_getRFP') {
        this.setAllSuppliers(result.text);
      }
  });
}

setAllSuppliers(value: any) {
   // sent object (DTO or boolean)
   this.quoteDTO = value;
   this.IsAllSuppliersGetRFP = // 'value from DTO' as boolean;
}