ng generate factory code example

Example 1: angular generate component

ng g component componentname

Example 2: create class angular

// to create a model class, we first need to create a new file
//f.e person.ts

export class Person {
 constructor(
  public name: string,
   public lastName: string,
   public age:number
  
  ) {}
}

//now that we have the model class we can create arrays that contain Person class elements

.
.
public people: Person[];
constructor(){
 this.people = [
   new Person ('Carla','Smith', 20 ),
    new Person ('Carlos','Smith', 25 ),
    new Person ('Andrea','Johnson', 23 ),
   
   ];
}

Example 3: angular cli interface generate

ng generate interface <name> <type> [options]
ng g interface <name> <type> [options]

# <name>	The name of the interface.
# <type>	Adds a developer-defined type to the filename, in the format "name.type.ts".
# [options]
#	--lintFix=true|false	When true, applies lint fixes after generating the interface (Default: false)
#	--prefix=prefix			A prefix to apply to generated selectors
#	--project=project		The name of the project.

# e.g.
# ng generate interface Itest sometype		generates file name		itest.sometype.ts