Show Menu
Cheatography

Angular CLI Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

ng new <na­me> [options]

--dry-run (alias: -d)
Run through without making any changes.
--force (alias: -f)
Forces overwr­iting files
--verbose (alias: -v)
Adds more details to output logging.
--coll­ection (alias: -c)
Schematics collection to use.
--inli­ne-­style (alias: -s)
Specifies if the style will be in the ts file.
--inli­ne-­tem­plate (alias: -t)
Specifies if the template will be in the ts file.
--view­-en­cap­sul­ation
Specifies the view encaps­ulation strategy.
--inli­ne-­tem­plate (alias: -t)
Specifies if the template will be in the ts file.
--view­-en­cap­sul­ation
Specifies the view encaps­ulation strategy.
--routing
Generates a routing module.
--prefix (alias: -p)
The prefix to apply to generated selectors.
--style
The file extension to be used for style files.
--skip­-tests (alias: -S)
Skip creating spec files.
--skip­-pa­cka­ge-json
Do not add depend­encies to packag­e.json.

ng generate [type] [path/­name]

class
Generates a class
component
Generates a component
directive
Generates a directive
enum
Generates a enumer­ation
guard
Generates a guard
interface
Generates an interface
module
Generates a module
pipe
Generates a pipe
service
Generates a service
You can also call it with ng g [type] [path/­name]

ng build [options]

--prod
Flag to set config­uration to "­pro­d".
--conf­igu­ration (alias: -c)
Specify the config­uration to use.
--main
The name of the main entry-­point file.
--poly­fills
The name of the polyfills file.
--ts-c­onfig
The name of the TypeScript config­uration file.
--opti­miz­ation
Defines the optimi­zation level of the build.
--outp­ut-path
Path where output will be placed.
--aot
Build using Ahead of Time compil­ation.
--sour­ce-map
Output source­maps.
--eval­-so­urc­e-map
Output in-file eval source­maps.
--vend­or-­sou­rce-map
Resolve vendor packages source­maps.
--vend­or-­chunk
Use a separate bundle containing only vendor libraries.
--comm­on-­chunk
Use a separate bundle containing code used across multiple bundles.
--base­-href
Base url for the applic­ation being built.
--depl­oy-url
URL where files will be deployed.
--verbose
Adds more details to output logging.
--progress
Log progress to the console while building.
--i18n­-file
Locali­zation file to use for i18n.
--i18n­-format
Format of the locali­zation file specified with --i18n­-file.
--i18n­-locale
Locale to use for i18n.
--i18n­-mi­ssi­ng-­tra­nsl­ation
How to handle missing transl­ations for i18n.
--extr­act-css
Extract css from global styles onto css files instead of js ones.
--watch
Run build when files change.
--outp­ut-­hashing
Define the output filename cache-­busting hashing mode.
--poll
Enable and define the file watching poll time period in millis­econds.
--dele­te-­out­put­-path
Delete the output path before building.
--pres­erv­e-s­ymlinks
Do not use the real path when resolving modules.
--extr­act­-li­censes
Extract all licenses in a separate file, in the case of production builds only.
--show­-ci­rcu­lar­-de­pen­dencies
Show circular dependency warnings on builds.
--buil­d-o­pti­mizer
Enables @angul­ar-­dev­kit­/bu­ild­-op­timizer optimi­zations when using the 'aot' option.
--name­d-c­hunks
Use file name for lazy loaded chunks.
--subr­eso­urc­e-i­nte­grity
Enables the use of subres­ource integrity valida­tion.
--serv­ice­-worker
Generates a service worker config for production builds.
--ngsw­-co­nfi­g-path
Path to ngsw-c­onf­ig.j­son.
--skip­-ap­p-shell
Flag to prevent building an app shell.
--index
The name of the index HTML file.
--stat­s-json
Generates a 'stats.json' file which can be analyzed using tools such as: #webpa­ck-­bun­dle­-an­alyzer' or https: //webp­ack.gi­thu­b.i­o/a­nalyse.
--fork­-ty­pe-­checker
Run the TypeScript type checker in a forked process.
 

ng serve [options]

--prod
Flag to set config­uration to "­pro­d".
--conf­igu­ration (alias: -c)
Specify the config­uration to use.
--brow­ser­-target
Target to serve.
--port
Port to listen on.
--host
Host to listen on.
--prox­y-c­onfig
Proxy config­uration file.
--ssl
Serve using HTTPS.
--ssl-key
SSL key to use for serving HTTPS.
--ssl-cert
SSL certif­icate to use for serving HTTPS.
--open (alias: -o)
Opens the url in default browser.
--live­-reload
Whether to reload the page on change, using live-r­eload.
--publ­ic-host
Specify the URL that the browser client will use.
--serv­e-path
The pathname where the app will be served.
--disa­ble­-ho­st-­check
Don't verify connected clients are part of allowed hosts.
--hmr
Enable hot module replac­ement.
--watch
Rebuild on change.
--hmr-­warning
Show a warning when the --hmr option is enabled.
--serv­e-p­ath­-de­fau­lt-­warning
Show a warning when deploy­-ur­l/b­ase­-href use unsupp­orted serve path values.
--opti­miz­ation
Defines the optimi­zation level of the build.
--aot
Build using Ahead of Time compil­ation.
--sour­ce-map
Output source­maps.
--eval­-so­urc­e-map
Output in-file eval source­maps.
--vend­or-­sou­rce-map
Resolve vendor packages source­maps.
--vend­or-­chunk
Use a separate bundle containing only vendor libraries.
--comm­on-­chunk
Use a separate bundle containing code used across multiple bundles.
--base­-href
Base url for the applic­ation being built.
--depl­oy-url
URL where files will be deployed.
--verbose
Adds more details to output logging.
--progress
Log progress to the console while building.

ng update [package]

--dry-run (alias: -d)
Run through without making any changes.
--force
If false, will error out if installed packages are incomp­atible with the update.
--all
Whether to update all packages in packag­e.json.
--next
Use the largest version, including beta and RCs.
--migr­ate­-only
Only perform a migration, does not update the installed version.
--from
Version from which to migrate from. Only available with a single package being updated, and only on migration only.
--to
Version up to which to apply migrat­ions. Only available with a single package being updated, and only on migrations only. Requires from to be specified. Default to the installed version detected.
--registry
The NPM registry to use.
Updates the current applic­ation to latest versions.