Dependency injection
All you need is the @autoinject annotation. The JS/HTML mapping is performed automatically by the framework:
class Ticket { /* class code, properties, methods... */ } @inject export class Sale {
constructor( ticket ) {} public activate() { // do something... this.ticket.toast("Sale processed!"); } }
For Typescript users, the annotation names are very similar. Use @autoinject instead of @inject and don't forget to specify the visibility and type of object in the constructor : constructor(private ticket : Ticket)
推薦閱讀
- 廣電5G從入門到精通
- 物聯(lián)網(wǎng)安全(原書第2版)
- OpenLayers Cookbook
- Learning QGIS 2.0
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- Mastering TypeScript 3
- 物聯(lián)網(wǎng)之霧:基于霧計(jì)算的智能硬件快速反應(yīng)與安全控制
- 圖解手機(jī)元器件維修技巧
- React Cookbook
- 云工廠:開啟中國制造云時(shí)代
- LwIP應(yīng)用開發(fā)實(shí)戰(zhàn)指南:基于STM32
- Selenium WebDriver 3 Practical Guide
- Microservices Development Cookbook
- 路由與交換技術(shù)
- 學(xué)術(shù)虛擬社區(qū)用戶社會(huì)化交互行為研究