Skip to main content

Commands

🏗️ Project Creation & Setup

CommandDescriptionExample
ng newCreate new Angular projectng new my-app
ng addAdd package to projectng add @angular/material
ng updateUpdate dependenciesng update @angular/core
ng configManage CLI configurationng config schematics.@schematics/angular:component.style scss

🚀 Development Commands

CommandDescriptionExample
ng serveRun development serverng serve --port 4201
ng buildBuild projectng build --prod
ng testRun unit testsng test --watch
ng e2eRun end-to-end testsng e2e --port 4201

🧩 Component Generation

CommandDescriptionExample
ng generate componentCreate new componentng g c user-profile
ng generate moduleCreate new moduleng g m admin
ng generate serviceCreate new serviceng g s data
ng generate directiveCreate new directiveng g d highlight
ng generate pipeCreate new pipeng g p currency-format

🏛️ Architecture Commands

CommandDescriptionExample
ng generate libraryCreate library projectng g lib shared
ng generate applicationCreate app in workspaceng g app admin
ng generate interfaceCreate interfaceng g i user
ng generate enumCreate enumng g enum status

🌐 Internationalization

CommandDescriptionExample
ng extract-i18nExtract i18n messagesng extract-i18n --output-path src/locale
ng serve --configurationServe with locale configng serve --configuration=fr

🔧 Utility Commands

CommandDescriptionExample
ng lintRun lintingng lint --fix
ng deployDeploy applicationng deploy --base-href=/my-app/
ng docSearch Angular docsng doc router
ng versionShow CLI versionng v

🛠️ Advanced Commands

CommandDescriptionExample
ng runRun custom targetng run my-app:server
ng cacheManage build cacheng cache clean
ng analyticsConfigure analyticsng analytics off
ng repairRepair configurationng repair

🎛️ Configuration Options

OptionDescriptionExample
--dry-runSimulate commandng g c demo --dry-run
--skip-testsSkip test filesng g c home --skip-tests
--styleStyle preprocessorng new --style=scss
--routingAdd routing moduleng new --routing

💡 Tips Penggunaan

  1. Gunakan shortcut:
    ng g c home  # untuk ng generate component home
    ng s -o # untuk ng serve --open

⚡ Tips Cepat

  • Gunakan --dry-run untuk melihat apa yang akan dibuat tanpa benar-benar membuatnya
  • --skip-tests untuk melewati pembuatan file test
  • --style=scss untuk menggunakan SCSS

💡 Gunakan ng help untuk melihat semua opsi yang tersedia