Node.js
npm (node package manager)
use of Node.js for Angular
package.json file
TypeScript
Single Page Application
Advantages and Disadvantages of SPAs
Advantages:
Disadvantages:
Variable declaration in TypeScript
let [identifier] : [type] = value;
Datatypes in TypeScript
Classes, Access Modifiers, Modules, Accessors and Mutators in TypeScript
Classes:
Access Modifiers:
Modules:
Accessors and Mutators:
- “get” and “set” keywords: create getter and setter methods
Decorator
Types of Decorators
Class decorators:
Method decorators:
Property decorators:
- used to listen to state changes on a class
Parameter decorators:
Accessor Decorators:
- applied to the property descriptor for the accessor
Interfaces
Webpack
Angular CLI
Angular file structure
AngularJS vs Angular 4+
AngularJS:
Angular 4+:
Component Life Cycle Hooks
constructor():
- executed first
- inject any dependencies into the component
ngOnChanges():
- called whenever the input properties of the component change
- returns a SimpleChanges object which holds any current and previous property values
ngOnInit():
- called once to initialize the component and set the input properties
- initializes the component after Angular first displays the data-bound properties
ngDoCheck():
- called during all change-detection runs that Angular can’t detect on its own
- also called immediately after the ngOnChanges() method
ngAfterContentInit():
- invoked once after Angular performs any content projection into the component’s view
ngAfterContentChecked():
- invoked after each time Angular checks for content projected into the component.
- called after ngAfterContentInit() and every subsequent ngDoCheck()
ngAfterViewInit():
- invoked after Angular initializes the component’s views and its child views
ngAfterViewChecked():
- invoked after each time Angular checks for the content projected into the component
- called after ngAfterViewInit() and every subsequent ngAfterContentChecked()
ngOnDestroy():
- invoked before Angular destroys the directive or component
Angular Components
@Component decorator
Angular Directives
Types of directives:
Structural Directives
3 built-in directives:
Attribute Directories
[ngClass]:
[ngStyle]:
custom directives:
- use CLI command “ng generate directive “
@NgModule decorator
NgModule takes metadata and describes how to compile a component’s template and how to create an injector at runtime. It identifies the module’s own components, directives, and pipes and makes them public through the export property which can be used by external components.
takes metadata to launch the app: