- Hands-On Full Stack Web Development with Angular 6 and Laravel 5
- Fernando Monteiro
- 99字
- 2021-07-23 19:18:51
Importing and using external classes
An import can be accomplished with the keyword import, and can be declared in different ways, depending on what library you are using. An example of using Require.js is as follows:
- Go back to your text editor, create a file called import.ts, and add the following code:
import MyBand = require('./export');
console.log(Myband());
An example of using Common.js is as follows:
import { MyBand } from './export';
console.log(new Myband(['ZZ Top', 'Motorhead'], 3));
- The second method has been adopted by the Angular team, because Angular uses Webpack, a module bundler building modern web applications.