Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you generate services etc. for a @nrwl/nx angular-cli app?

Normally when using @angular/cli to develop an application, you add a new service in the following manner:

ng generate service foo

This would generate "FooService".

My question is, when you have generated a library using @nrwl/nx, how do you add a service to it?

ng generate lib foo-lib

What I want to know, is the command to generate service "foo", so that it lives in the foo-lib library.

like image 274
Bryan Rayner Avatar asked Nov 28 '22 06:11

Bryan Rayner


2 Answers

For nx vesion 6.1, this is the right way:

ng g service my-service --project=myNameOrLibName
like image 138
Дніщенко Денис Avatar answered Dec 23 '22 07:12

Дніщенко Денис


It just works with the angular-cli command, but you have to add the --app flag

ng g service foo --app=foo-lib

It is also mentioned in the docs of Nx under "Leverage the AngularCLI".

like image 21
Michael Warneke Avatar answered Dec 23 '22 05:12

Michael Warneke