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)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset