How to generate model class in angular using CLI


Using Angular CLI we can quickly generate component structure. Before that make sure you have

  1. npm
  2. angular CLI

preinstalled on your system. For better understanding of angular project structure I suggest the following post

Install CLI

If you already have the angular CLI installed , skip this step

npm install @angular/cli

Model

Model is a class used to store data for specific purposes. For example a Model class can be used to capture data in a template driven forms.

Generate class

Use the following command to generate class from the project root

ng g class model-class-name  // say User

Don’t forget to visit the source code page

Published by

Manoj

A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.