Dealing with models and classes
Considered good practice by the community of Angular developers (and we consider it essential) is the creation of classes to use them as models. These are also known as domain models.
We believe that creating classes to store our models in is a very important resource for creating large-scale applications or even small apps. This helps you keep your code organized.
Imagine if our project is much larger—if all the data was stored inside the plain objects, it would be hard for a new developer to find out where the data is stored.
This is also a good reason to use classes to store our model information.
Creating the User class model
Let's start by creating the class to store our user information. By convention, we will name this file user.ts
:
Open your Terminal window.
Go to
./Client/src/app
and type the following command:
ng g class pages/auth/user
- The previous command will create a new file in
./app/pages/auth/auth.ts
. Open this file and add the following code:
export...