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

Use angular-cli proxy for multiple backends
chunk files size are multiplied by 5 on build size ng build --prod
AngularCli: disable minification
Angular Cli e2e element explorer not responding
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

Categories

HOME
cil
websphere
sed
wsdl
laravel-5.2
is-empty
snap.svg
goutte
unity2d
packer
criteria
wysiwyg
squarespace
glpk
ssms-2016
r-lavaan
arm-template
pycrypto
onesignal
metis
hash-collision
pitest
devforce
xor
encase
rhel.net
es-shell
initializer
fax
jquery-multidatespicker
infusionsoft
polyfills
android-preferences
rule
lexical-analysis
wsadmin
bayesian-networks
jupyter-console
paho
finite-element-analysis
php-ews
rhel6
rpostgresql
addin-express
keycode
iostat
children
spoofing
brython
logcat
fill
fortran90
git-rebase
approval-tests
cctray
enyo
matcaffe
sevenzipsharp
ipojo
base32
rx-groovy
sysfs
viewflipper
named-ranges
ultrawingrid
grunt-express
iostream
csplit
bullet
valence
ifft
visualstatemanager
chrome-for-android
healthvault
visual-studio-addins
sqljdbc
angulartics
bignum
convex-polygon
nscolor
javascriptmvc
swrl
html-form-post
gridworld
ng-pattern
google-closure-library
qtgui
fortran77
fieldset
xgettext
flexicious
emacs23
selectmanycheckbox
msbuildextensionpack
collect
nagle
pureftpd
hadoop-plugins
multibyte-functions
callgrind
winsnmp
visual-studio-dbpro

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