- Hands-On Full Stack Web Development with Angular 6 and Laravel 5
- Fernando Monteiro
- 116字
- 2021-07-23 19:18:51
Using the class export feature
Any declaration can be exported, as we mentioned previously; to do so, we just need to add the export keyword. In the following example, we will export the band class.
In your text editor, create a file called export.ts, and add the following code:
export class MyBand {
// Properties without prefix are public
// Available is; Private, Protected
albums: Array<string>;
members: number;
constructor(albums_list: Array<string>, total_members: number) {
this.albums = albums_list;
this.members = total_members;
}
// Methods
listAlbums(): void {
console.log("My favorite albums: ");
for(var i = 0; i < this.albums.length; i++) {
console.log(this.albums[i]);
}
}
}
We will now have our Myband class available to be imported into another file.
推薦閱讀
- 物聯網工程規劃技術
- HCNA網絡技術
- Getting Started with WebRTC
- Mastering TypeScript 3
- 數字調制解調技術的MATLAB與FPGA實現:Altera/Verilog版(第2版)
- 圖解手機元器件維修技巧
- 通信原理及MATLAB/Simulink仿真
- INSTANT KineticJS Starter
- 物聯網場景設計與開發(初級)
- Learning Storm
- 物聯網工程概論
- Microsoft Power Platform Enterprise Architecture
- 數字王國里的虛擬人:技術、商業與法律解讀
- Migrating to Drupal7
- 5G時代:生活方式和商業模式的大變革