-
Angular
- Install Angular CLI globally (one time setup)
npm install -g @angular/cli ng version
- Open project in vsCode (command run in the project directory)
code .
- Create Angular App
ng new project-name
- Run the project and open http://localhost:4200
ng serve
- Create new Angular Component
ng generate component componentName --dry-run --skip-tests --module=app --skip-import
- Create new Angular Service
ng generate service service-name
- Lazy loading
ng generate module name --route name --module app.module
✖ Error: Invalid Character (typing ng --version in the terminal)
Solution: Use bash (workaround)
✖ Error: Property 'name' has no initializer and is not definitely assigned in the constructor.
Solution: Add "strictPropertyInitialization": false
in the compiler options of the tsconfig.json or a default value to the property.
✖ Error: Can't bind to 'ngModel' since it isn't a known property of 'input'.
Solution: Add FormsModule and ReactiveFormsModule to the imports array in app.module.ts.
✖ Error: Angular Material installation: No terminal detected. '--skip-confirmation' can be used to bypass installation confirmation. Ensure package name is correct prior to '--skip-confirmation' option usage.
Solution: Type the command: npm install --save @angular/material @angular/cdk @angular/animations and then ng add @angular/material with git bash.