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.
For nx vesion 6.1, this is the right way:
ng g service my-service --project=myNameOrLibName
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With