We have a typescript class,which contains few methods. Sample example of the TypeScript class.
export class AppointmentListComponent implements OnInit {
editEvent(event: IEvent): void {
this._router.navigate(['/appointments', event.id]);
}
}
We want to call editEvent method from another (.js) file. How can we achieve this.
If you are working with ES6 it's pretty simple. In typescript just use import "pathToJSModule";
and you are ready to use it. This is possible because JS is a valid Typescript.
If you are not working with ES6 you can use import * as foo from "pathToFile"
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.