Angular Command Line Interface
Zur Navigation springen
Zur Suche springen
Installation
Neu
sudo npm install -g @angular/cli
Update
npm uninstall -g @angular/cli npm cache verify # if npm version is < 5 then use `npm cache clean` npm install -g @angular/cli@latest
Konfiguration
Umgebungsvariable für Google Chrome (Chromium) setzen:
vi ~/.bashrc
Am Ende folgende Zeile hinzufügen:
export CHROME_BIN=/usr/bin/chromium-browser
Verwendung
Aufruf
npm run ng <command>
Klasse erstellen
ng generate class <class name>
Komponente erstellen
ng generate component [-s] <table name>
kurz | lang | Bedeutung |
---|---|---|
-s | --inline-style | Es wird keine CSS-Datei erstellt |
Modul erstellen
ng g module <module name> --routing
Projekt erstellen
ng new <project name> --prefix <prefix>
Routen erstellen
ng generate module app-routing --flat --module=app
Guard erstellen
ng g guard <guard name>
Links
https://gnomeontherun.com/2017/03/02/guards-and-login-redirects-in-angular/
Production Build
ng build --prod
Links
https://angular.io/guide/deployment
https://angular.io/guide/deployment#fallback
Service erstellen
ng generate service <service name>
Links
https://angular.io/tutorial/toh-pt5
Built-In-Server starten
ng serve
Testen
ng test
Probleme
Could not find module "@angular-devkit/build-angular" from
npm install --save-dev @angular-devkit/build-angular
Your global Angular CLI version (6.2.5) is greater than your local version (6.0.8). The local Angular CLI version is used.
npm install --save-dev @angular/cli@latest
Zurück zu JavaScript