(07.10.2018)
Based on book "Angular - das umfassende Handbuch"
by Andreas Höller
in current folder)
Public: Tutorial
| Wiki
| Blog
This Wiki: Angular Binding | Angular Routing | Angular CSS | Angular Best Practices | Angular Project Steps
is a runtime environment for javascript on the server, details
. It uses the Node Package Manager (npm).
and install
> npm lite-server (config via "packages.json" > "scripts") > concurrently "tsc -p "TypeScriptFiles" -w" "lite-server"
#shs.serverPort 8080 shs.serverHost 127.0.0.1 shs.mainFile index.htmlStart with F1 >
shs.createServer Simple HTTP Server: Create HTTP Server shs.createServerWithSingleFile Simple HTTP Server: Create HTTP Server With Current Filehttp://127.0.0.1:8080
npm install -g @angular/cli ng --version ng helpOption -g installs the global CLI version. This is necessary to initially use "ng new". When you have created a project you use the local CLI version, which is then independent from the global one.
npm i npm to updateTo install / update the local one use
npm install @angular/cli npm install --save-dev @angular/cli@latest ng update <= THIS IS TO ANALYZE ng update @angular/core ng update --allThis will add entry "@angular/cli": "^6.2.4" at devDependencies in your package.json.
npm install -g @angular/cli@latest npm update -g --all
Align file package-lock.json
Versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install. Please make sure your package.json contains both @angular/compiler-cli and typescript in devDependencies, then delete node_modules and package-lock.json (if you have one) and run npm install again.
#ng serve (in memory without files) ng build --watch (with files)Parameter possible: --proxy-config proxy.conf.json (CORS)
ng new Test002 ng new Test003 --prefix=me --routing=trueNote: you need to choose a CSS stylesheet format
Packages used are specified with package.json
npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest cd projectFolder rm -rf node_modules dist tmp npm install --save-dev @angular/cli@latest npm install ng init > overwrite/skip/diff ? > npm start = start project via npm and file "package.json" (uses devDependencies modules, not global ones)\\ (add parameter in "scripts" via "--": "npm start -- --port 8080")\\
Generate
ng generate module app-routing --flat --module=app ng generate component hello-cli (short: ng g c hello-cli) = add component later\\ ng g directive|pipe|service|module|class|interface|enum\\ ng lint (linter TSLint) = static code validation based on file "tslint.json"\\
automated tests:
Libraries
npm install --save lodash npm install --save-dev @types/lodash (scoped package for lodash to add types) npm install --save bootstrap npm install --save jquery npm install --save @types/jquery npm install --save velocity-animate npm install --save rxjs npm install --save rxjs-compat npm install --save fancyboxSee velocity.js
, Bootstrap
They are added in angular.json (not in index.html) automatically, you can add custom ones, too:
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js",
"node_modules/velocity-animate/velocity.min.js",
"src/assets/js/ebel-animate.js"
]
component:
import * as $ from 'jquery';
import * as velocity from 'velocity-animate';
const myElement = $('.header');
velocity(myElement, {
left: param_diff_left,
top: param_diff_top,
width: param_diff_with
}, { duration: 900 });
ng build (creates dev deployment in folder "dist", uses global modules; to use local ones create script in npm) ng build --prod (compare angular-cli.json > "environments") ng build --target=production --environment=prod ng serve --prod ng build --prod -aot
backtick(`) = span string over multiple lines and add instance variables via name called interpolation
in opposite to property-binding
"export" = enables other modules to import the class
<!-- Polyfill(s) für ältere Browser -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
file systemjs.config.js specifies for SystemJS via "map" where to find modules (for "import") and packages and main file
ng build --prod --aot=false --build-optimizer=falsehttps://angular.io/docs/ts/latest/cookbook/aot-compiler.html
