A
A
Agnik2019-10-01 11:07:33
Angular
Agnik, 2019-10-01 11:07:33

Why can't VSCode and Agnular see the classes in the models folder?

Good afternoon.
There are two classes in the models folder: product.ts and user.ts
In the component I try to include them: import {Product, User} from '../../models'.
Swears: Cannot find module '../../models'.
What am I doing wrong? because somewhere in the examples I saw that this is possible.
Yes, I can include them via import { Product} from '../../models/product.ts', but damn..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScarletFlash, 2019-10-07
@ScarletFlash

In the models folder, you need to create index.ts and describe the exports there: for example, export * from ./product.ts.
This is called barrel import.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question