中间人模式

app HTML


从子组件拿到的股票代码是{ {priceQuote.stockCode}}.股票的价格是{ {priceQuote.lastprice | number:'00.1-2'}}

app TS

export class AppComponent {
  priceQuote: PriceQuote = new PriceQuote('', 0);

  // tslint:disable-next-line:typedef
  buyHandler(event: PriceQuote){
    this.priceQuote = event;
  }
}

pricequote HTML

股票代码是{ {stockId}},股票价格是{ {price | number: '00.1-2'}}

priceQuote TS

  buyStock(event): void{
    this.buy.emit(new PriceQuote(this.stockId, this.price));
    return null;
  }

order HTML

我要买100手的{ {priceQuote.stockCode}}的股票,价格是{ {priceQuote.lastprice | number:'00.1-2'}}股票!

order TS

export class OrderComponent implements OnInit {
  @Input()
  priceQuote: PriceQuote;
  constructor() {
  }

  ngOnInit(): void {
  }

}

 

你可能感兴趣的:(angular)