component.ts
The component.ts file contains two classes.
Template
This class is used internally to represent a HTML template and contains some addition information pertaining to its name and whether it has been successfully fetched from the server
Component
This is the foundation class of JSPA. All components should extend the Component class. The basic structure of a user component is shown below. More information regarding creating application specific components is discussed in "Components (dir)"
/// <reference path="../../Application/component.ts" />
class MyClass extends Component {
constructor(){
super("url/to/template.html");
}
draw(args: any): Promise<JQuery> {
return new Promise((resolve) =>{
return $("<h1>Content</h1>");
}
}
}
The Component class contains all of the logic for data binding to templates, and accessing the rendered view.
All application specific components must contain a constructor()
which calls super()
that paramters passed to super()
are the html templates that this component will have access to.
Each component must also decalre the draw(args: any)
method, this is the access route into the componetns logic used by the routing.