Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put regular classes in Angular app?

Tags:

angular

Assuming my app's structure looks like this:

|-- app
    |-- components
    |-- features
    |-- models
    |-- pipes
    |-- services
    |-- views

And now I've made a regular class with a few methods and @Output so that several components may extend this class. Should I create a folder "classes"? I've never seen this in the docs or articles.

like image 830
Christian Avatar asked Jan 25 '18 19:01

Christian


2 Answers

If it has @Output as you say but it's not a component - I presume it's for other components to inherit? In this case I like to call them base components, I'll usually drop them within components a level higher than the inheriting components.

For example:

|-- app
    |-- components
        |-- fancy-table
            |-- small-fancy-table
                |-- small-fancy-table.component.ts
                |-- small-fancy-table.component.html
            |-- large-fancy-table
                |-- large-fancy-table.component.ts
                |-- large-fancy-table.component.html
            |-- base-fancy-table.component.ts <-- The class you're referring to.
    |-- features
    |-- models
    |-- pipes
    |-- services
    |-- views
like image 68
UncleDave Avatar answered Sep 21 '22 17:09

UncleDave


You already have models folder, you could create interface/class according to your need

like image 28
Sajeetharan Avatar answered Sep 21 '22 17:09

Sajeetharan