Tutorial by Examples

You can use the ng generate or ng g command to generate Angular building blocks (components, services, pipes, etc.). You can find all possible blueprints in the table below: ScaffoldUsageShortenedComponentng generate component component-nameng g c component-nameDirectiveng generate directive direc...
To add a component with a selector [prefix]-user-list, run: $ ng g c user-list installing component create src/app/user-list/user-list.component.css create src/app/user-list/user-list.component.html create src/app/user-list/user-list.component.spec.ts create src/app/use...
To add a directive with a selector [prefix]Highlight, run: $ ng g d highlight installing directive create src/app/highlight.directive.spec.ts create src/app/highlight.directive.ts update src/app/app.module.ts To prevent prefix usage add --prefix false or -p false flag ...
To add a service with a name UserService, run: $ ng g s user installing service create src/app/user.service.spec.ts create src/app/user.service.ts To prevent .spec files creation add --spec false or -sp false flag $ ng g s user --spec false installing service ...
To add a pipe with a name searchByName, run: $ ng g p search-by-name installing pipe create src/app/search-by-name.pipe.spec.ts create src/app/search-by-name.pipe.ts update src/app/app.module.ts To prevent .spec files creation add --spec false or -sp false flag $ ng ...
To add a module called GuestModule, run: $ ng g m guest installing module create src/app/guest/guest.module.ts To enable .spec files creation add --spec or -sp flag $ ng g m guest --spec installing module create src/app/guest/guest.module.spec.ts create src/app/...

Page 1 of 1