=================================================================================
=================================================================================
Node: 8.X
npm: 5.x
Run PowerShell as Administrator
- Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
- $ npm install -g npm-windows-upgrade
- $ npm-windows-upgrade
Download latest executable from here: https://nodejs.org/en/download/
$ node -v
$ npm -v
- Fresh Installation: $ npm install -g @angular/cli
- Upgrade: $ npm install -g @angular/cli@latest
$ ng -v
Creating a new Angular 6 project and all the required files with --skip-tests option to skip generating test files:
$ ng new Angular6Project --skip-tests
- Go to the project directory: cd Angular6Project
- Builds and launches the default browser and serves the application using the default port number 4200: ng serve --open (shortcut command : ng s -o)
$ npm install bootstrap@3 jquery --save
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
]
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
Creating employee(create-employee) component with no unit test files (--spec=false) and dedicated folder(--flat=true):
$ ng g c employee/create-employee --spec=false --flat=trueCreating employee(list-employees) component with no unit test files (--spec=false) and dedicated folder(--flat=true):
$ ng g c employee/list-employees --spec=false --flat=true- Separation of concerns
- Maintainability
$ ng g c my-component
$ ng g s my-service
$ ng g m my-module
$ ng g m my-module --routing
Generate routing module (app-routing) with no dedicated folder and include routing module to root (app) module:
$ ng g m app-routing --flat=true --module=app
1. Template Driven Forms ( All Codes are completely in HTML )
2. Reactive Forms (Also called Model Driven Forms and Reactive forms on the other hand allow us to build the form completely in code. )
Classes for creating a form control tree:
- FormGroup
- FormControl
formGroup directive: Binds 'form' element to FormGroup instance.
formControlName directive: Binds input element to FormControl instance
Both FormControl and FormGroup classes inherit from AbstractControl base class.
The AbstractControl class has properties that help us track both FormControl and FormGroup value and state.
### AbstractControl Class Properties:- value
- errors
- valid
- invalid
- dirty
- pristine
- touched
- untouched
eg: employeeForm.controls.fullName.value
OR
employeeForm.get('fullName').value
- setValidators()
- clearValidators()
- updateValueAndValidity()
- setValue()
- patchValue()
- Reset()
To group the form elements in the HTML, encapsulate the form elements in a div element and use the formGroupName directive on that container div element. Bind the formGroupName directive to the skills FormGroup instance in the component class. Bind each input element in the HTML, to the corresponding FormControl instance using the formControlName directive.
- Use setValue() to update all form control but not a subset of form control.
- Use patchValue() to update a subset or all of form control.
FormBuilder reduces the amount of boilerplate code we have to write to build complex reactive forms
=================================================================================
$ npm install bootstrap@3 jquery --save
$ ng g c employees/listEmployees --spec false --flat true
=================================================================================
$ npm install --save-dev @angular-devkit/build-angular