Angular Command Line Interface: Unterschied zwischen den Versionen

Aus Tutorials
Zur Navigation springen Zur Suche springen
 
(17 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 20: Zeile 31:


== Verwendung ==
== Verwendung ==
=== Aufruf ===
<pre>
npm run ng <command>
</pre>
=== Klasse erstellen ===
<pre>
ng generate class <class name>
</pre>
=== Komponente erstellen ===


<pre>
<pre>
ng new my-first-project
ng generate component [-s] <table name>
</pre>
</pre>
{| class="wikitable"
|-
!kurz
!lang
!Bedeutung
|-
| -s
| --inline-style
| Es wird keine CSS-Datei erstellt
|}
=== Modul erstellen ===
<pre>
ng g module <module name> --routing
</pre>
=== Projekt erstellen ===
<pre>
ng new <project name> --prefix <prefix>
</pre>
=== Routen erstellen ===
<pre>
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>
==== Links ====
[https://angular.io/tutorial/toh-pt5 https://angular.io/tutorial/toh-pt5]
=== Built-In-Server starten ===


<pre>
<pre>
ng serve
ng serve
</pre>
</pre>
=== Testen ===


<pre>
<pre>
Zeile 38: Zeile 128:


<pre>
<pre>
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