主题已订阅但未获得价值

时间:2019-07-04 10:01:04

标签: angular

  

ps1 html

<p-dataTable [value]="summaryListCement" [sortMode]="multiple" 
[paginator]="true" [rows]="10" [rowsPerPageOptions]="[10,20,30,40]" 
[responsive]="true" [editable]="false" 
[(selection)]="selectedId">
    <p-column field="description" header="Name"></p-column>
    <p-column header="Place Order">
      <template let-selectedId="rowData" pTemplate type="body">
     <button [routerLink]='["/placeOrder"]'  
     class="btn btn_post"(click)="placeOrderPage(selectedId.description)"
     type="button" style="width: 100px;" [disabled]="selectedId.enable == 
     0">
     Place Order
     </button>
   </template>
  </p-column>

</p-dataTable>
  

ps1组件

constructor(private productService: ProductCatalogService){}

 placeOrderPage(name){
    this.productService.placeOrderVal.next(name);
}
  

p服务

@Injectable()
 export class ProductCatalogService{

  public placeOrderVal = new Subject<any>();
}
  

ps2组件

ngOnInit() {
    this.productService.placeOrderVal.subscribe(data => { 
        console.log('plceorder'+data); 
    });
}
  

主题已订阅,但我无法从主题中获取价值。

我也可以观察但不能正常工作

  

我错了什么?

0 个答案:

没有答案