Friday, 28 December 2018

How Generate class, interface and enum by using Angular CLI?

To generate a class:

ng generate class className 

or 

ng g cl className 


To create a class in a specific folder:

C:\Windows\System32\AngularDemo>ng g cl employeeDetails/employee

Output:

CREATE src/app/employeeDetails/employee.ts (26 bytes)

employeeDetails is the folder where employee class is created.

By default, a spec file is not created for the class. If you want a spec file to be generated set --spec option to true.

ng g cl employee/employee --spec=true 

To generate an interface:

ng generate interface interfaceName 

or 

ng g i interfaceName 

To generate an enum:

ng generate enum enumName 

or 

ng g e enumName 

If you want to create interface and enums in a separate folder follow the same process what we applied for the class.

No comments:

Post a Comment