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
.spec
files creation add --spec false
or -sp false
flag$ ng g s user --spec false installing service create src/app/user.service.ts
--flat false
or -f false
flag$ ng g s user --flat false installing service create src/app/user/user.service.spec.ts create src/app/user/user.service.ts
You can also combine flags listed above. For example, to create only user.service.ts
file inside user
folder without .spec
file use the following command.
$ ng g s user -f false -sp false installing service create src/app/user/user.service.ts
All generate service
flags:
Description | Flag | Shortened | Default Value |
---|---|---|---|
Enable folder creation | --flat false | -f false | true |
Prevent .spec files creation | --spec false | -sp false | true |