2. Setup Folder Structure

We are going to use Angular factory for implementing subtyping. Comparing with the previous parts, the biggest changes are adding some files for "Book", "Person", "Author" and "Employee" factories.

Building an Angular factory is almost like to buiding a JavaScript model class. We set up the folder structure according to Model(Factory)-View-Controller:

Figure 15.4. Web Application with Factory

Web Application with Factory


publicLibrary
|-- index.html
|-- js
|   |-- app.js
|   |-- controllers.js
|   |-- controllersPackage
|   |   |-- AuthorsController.js
|   |   |-- BooksController.js
|   |   |-- EmployeesController.js
|   |   `-- TestDataController.js
|   |-- models.js
|   `-- modelsPackage
|       |-- AuthorsModel.js
|       |-- BooksModel.js
|       |-- EmployeesModel.js
|       `-- PersonsModel.js
`-- partials
    |-- authors
    |   `-- ...
    |-- books
    |   `-- ...
    |-- employees
    |   `-- ...
    `-- main.html