angular-cli


Angular cli generate a service and include the provider in one step


It is possible generate a service with angular cli and add it as a provider in the app.module.ts in a single step or using an special option in the ng g service command?
When a execute:
$ ng g service services/backendApi
installing service
create src/app/services/backend-api.service.spec.ts
create src/app/services/backend-api.service.ts
WARNING Service is generated but not provided, it must be provided to be used
Next to it, (and according to the WARNING message) I usually add it to provider section on app.module.ts using the text editor:
#NgModule({
declarations: [
AppComponent,
...
],
imports: [
....
],
providers: [BackendApiService],
bootstrap: [AppComponent]
})
It is possible to do it with a single step, to automatize this?
Actually, it is possible to provide the service (or guard, since that also needs to be provided) when creating the service.
The command is the following...
ng g s services/backendApi --module=app.module
Edit
It is possible to provide to a feature module, as well, you must give it the path to the module you would like.
ng g s services/backendApi --module=services/services.module

Related Links

Angular cli generate a service and include the provider in one step
Angular-cli not generating dist directory with ng build
How to update service json or array value on click in angular2?
How to revert from Angular-cli to Angular without cli for server-side rendering with Angular Universal
How to change file index outside the root
angularCLI Access-Control-Allow-Origin Multiple Origin Domains
Angular CLI how to merge json files
Angular CLI (ng) use single instead of double quotes
can't install angular cli on ubuntu 16.04
How to solve No 'Access-Control-Allow-Origin' header is present on the requested resource with angular 2 service written with angular-cli?
Usage of watch parameter in eject command of Angular CLI
Serving and testing a bundle after ng build
routerLink stopped working in #angular/cli
How to run Angularcli project with https
what is npm i bootstrap#next?
Angular-Cli Best way to manage notices

Categories

HOME
python
laravel-5
converter
google-cloud-bigtable
openssl
dynamics-crm
jsviews
wmic
mapping
matplotlib
heap-memory
propertygrid
jrebel
schemacrawler
cockroachdb
cakephp-2.9
android-source
viber
mod-pagespeed
lenskit
yeoman-generator
jsonserializer
sensu
thingsboard
cocoa-touch
memsql
bcrypt
onesignal
aurelia-binding
jackson-dataformat-csv
lmdb
division
windows-10-iot-core
oscommerce
vsts-package-management
liquid-xml
office365connectors
socketpair
declare
code-behind
delphi-10.1-berlin
php-ews
dojox.grid.datagrid
email-parsing
vcf
data-integration
chown
sapui
applepayjs
tofixed
photography
fontconfig
festival
sqldatareader
gulp-typescript
icefaces
try-finally
tomcat5
bacnet
dojox.charting
jackson-databind
com-interop
mercurial-hook
brackets-shell
web-essentials
hornetq
response-headers
castle-windsor-3
debian-based
ejabberd-saas
cpan
viewflipper
kendo-mvvm
firebug-lite
libssh2
power-law
aquafold
proxies
smartystreets
ifft
dvcs
late-static-binding
db4o
edit-in-place
exiv2
gamepad
.net-cf-3.5
robospice
driver-signing
mstsc
iconv
symphony-cms
fortran77
snapjs
sequelpro
static-variables
scrollto
ninject-extensions
getstring
z-machine
tcxgrid
surf
associative
pantheios
exitstatus
querypath
callgrind
system-codedom-compiler
standardized

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App