Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 import statement wildcard syntax

I defined several classes in one file like this

my.classes.ts

export class Class1 {....}
export class Class2 {....}
export class Class3 {....}

Now I want to import them all using wildcard like this

import {*} from './my.classes';

It showed syntax error.

What is the correct syntax to import * from a module?

like image 892
Shawn Avatar asked Apr 13 '26 04:04

Shawn


1 Answers

Here you go,

 import * as MyClasses from './my.classes';
 
 MyClasses.Class1 ....
like image 160
Madhu Ranjan Avatar answered Apr 16 '26 00:04

Madhu Ranjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!