Angular Command Line Interface: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(12 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
== Installation == | == Installation == | ||
=== Neu === | |||
<pre> | <pre> | ||
sudo npm install -g @angular/cli | sudo npm install -g @angular/cli | ||
</pre> | |||
=== Update === | |||
<pre> | |||
npm uninstall -g @angular/cli | |||
npm cache verify | |||
# if npm version is < 5 then use `npm cache clean` | |||
npm install -g @angular/cli@latest | |||
</pre> | </pre> | ||
Zeile 21: | Zeile 32: | ||
== Verwendung == | == Verwendung == | ||
=== | === Aufruf === | ||
<pre> | <pre> | ||
ng | npm run ng <command> | ||
</pre> | |||
=== Klasse erstellen === | |||
<pre> | |||
ng generate class <class name> | |||
</pre> | </pre> | ||
Zeile 44: | Zeile 61: | ||
|} | |} | ||
=== | === Modul erstellen === | ||
<pre> | <pre> | ||
ng | ng g module <module name> --routing | ||
</pre> | </pre> | ||
=== | === Projekt erstellen === | ||
<pre> | <pre> | ||
ng | ng new <project name> --prefix <prefix> | ||
</pre> | </pre> | ||
Zeile 60: | Zeile 77: | ||
<pre> | <pre> | ||
ng generate module app-routing --flat --module=app | ng generate module app-routing --flat --module=app | ||
</pre> | |||
=== Guard erstellen === | |||
<pre> | |||
ng g guard <guard name> | |||
</pre> | |||
==== Links ==== | |||
[https://gnomeontherun.com/2017/03/02/guards-and-login-redirects-in-angular/ https://gnomeontherun.com/2017/03/02/guards-and-login-redirects-in-angular/] | |||
=== Production Build === | |||
<pre> | |||
ng build --prod | |||
</pre> | |||
==== Links ==== | |||
[https://angular.io/guide/deployment https://angular.io/guide/deployment] | |||
[https://angular.io/guide/deployment#fallback https://angular.io/guide/deployment#fallback] | |||
=== Service erstellen === | |||
<pre> | |||
ng generate service <service name> | |||
</pre> | </pre> | ||
Zeile 84: | Zeile 129: | ||
<pre> | <pre> | ||
npm install --save-dev @angular-devkit/build-angular | npm install --save-dev @angular-devkit/build-angular | ||
</pre> | |||
=== Your global Angular CLI version (6.2.5) is greater than your local version (6.0.8). The local Angular CLI version is used. === | |||
<pre> | |||
npm install --save-dev @angular/cli@latest | |||
</pre> | </pre> | ||
Zurück zu [[JavaScript#Programme|JavaScript]] | Zurück zu [[JavaScript#Programme|JavaScript]] |
Aktuelle Version vom 30. November 2021, 20:13 Uhr
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