This is a draft cheat sheet. It is a work in progress and is not finished yet.
Create Workspace
ng new [projectname] --create-application=false |
For next commands: cd [projectname]
Create application
ng generate application [applicationname] |
Create Library
ng generate library [libraryname] --prefix=[prefix] |
ALWAYS: Use a prefix when generating a library.
Use library in application
Add to src\app.module.test |
import { librarynameModule } from 'libraryname'; add librarynameModule in imports array |
add to html-file |
<prefix-libraryname></prefix-libraryname> |
Before using a library: build the library: ng build [libraryname] ALWAYS: In your test application import using your library by name and NOT the individual files.
Build, serve and test
build library |
ng build [libraryname] |
build application |
ng build [applicationname] |
serve application |
ng serve [applicationname] --prod |
test library |
ng test [libraryname] |
test application |
ng test [applicationname] |
Will be served on localhost:4200
|
|
New components
generate |
ng generate component [modulename] --project=[libraryname/applicationname] |
add to .module.ts export array |
if library |
Angular material
add angular material |
ng add @angular/material |
Add components to src/app/app.module.ts |
import { MatInputModule, MatButtonModule, MatSelectModule, MatIconModule } from '@angular/material'; import { FormsModule } from '@angular/forms';
imports: [ BrowserModule, BrowserAnimationsModule, FormsModule, MatInputModule, MatButtonModule, MatSelectModule, MatIconModule ], |
|