to build dynamic single-page applications (SPAs). It's developed and maintained by Google and allows developers to create single-page applications (SPAs) using TypeScript,HTML, and CSS.SCSS, SASS etc. Introduction to Angular
released in November 2022 Angular 14 is released in June 2022 Angular 12 is released in May & Angular 13 is released in Nov 2021 Angular 10.0 was released in June & Angular 11.0 was released in Nov 2020 Angular 9.0 was released in Feb 2020 Angular 8.0 was released in May 2019 Angular 6.0 in May Angular 7.0 was released in Oct 2018 Angular 4.0 in March & Angular 5.0 was released in Nov 2017 Angular version 2.0 was released in September 2016 Angular version 1.0 (AngularJS) was released in 2012 by Google Angular History
framework, and it’s scheduled to be released in May 2023. I’m excited about this release, which includes several new features and improvements I’ve been looking forward to: • Required Component Inputs • Bind Router information to component inputs • Angular Signals developer preview • Standalone component • Images Optimization reduce to load time in the view What is new angular v16.0
a solid understanding of a few foundational technologies and concepts. Here are some prerequisites that can make learning Angular smoother and more effective. • HTML, CSS, and JavaScript • TypeScript • Angular CLI • Web Development Basics • Version Control (e.g., Git) • Node.js and npm • HTTP and APIs • Dependency Injection Requirements for Angular
build --env Build and Run ng serve Testing ng test End-End Testing ng e2e • Displays help information about CLI commands and options. • Displays help information about CLI commands and options. • Compiles and serves the application locally for development. • Runs unit tests using testing frameworks like Jasmine and Karma. • Runs end-to-end (e2e) tests using tools like Protractor
g m my-module Component ng generate component my-component ng g c my-component Directive ng generate directive my-directive ng g d my-directive Pipe ng generate pipe my-pipe ng g p my-pipe Service ng generate service my-service ng g s my-service Guard ng generate guard my-guard ng g g my-guard Class ng generate class ng g cl my-class Angular CLI Commands
choice, especially if you want to leverage your existing Angular skills for web development. Angular is a popular JavaScript framework for building dynamic and responsive web applications. When it comes to mobile apps, Angular can be used in combination with tools like Ionic to create cross-platform mobile applications. Here's a high-level overview of the process • Setup • Choose a Mobile Framework • Development • Styling and Theming • Adding Functionality • Native Features • Testing • Building • Deployment Mobile apps with Angular
to establish a connection between user interface elements and underlying data models. It allows changes in one to automatically update the other. There are two main types of data binding • One-Way Data Binding • Two-Way Data Binding: Data Binding in Angular
the data model) to the target (usually a UI element). In this approach, changes in the source will automatically update the target, but changes in the target won't affect the source. One-way data binding is often used when you want to display data to the user, but you don't expect the user's actions to directly modify the data. It simplifies the process of displaying information without having to manually update the UI elements each time the data changes. One-Way Data Binding
to updating the target when the source changes, two-way binding also updates the source when the target changes. This means that changes made by the user in the UI will also update the underlying data model. Two-Way Data Binding:
allows you to transform data before displaying it in a template. They are a way to format and manipulate values directly in the template, making it easier to present data in a user-friendly manner. Angular provides several built-in pipes for common tasks like formatting dates, numbers, and strings, as well as filtering and sorting arrays. Some commonly used built-in pipes include: • DatePipe: Formats dates. • DecimalPipe: Formats numbers as decimals. • CurrencyPipe: Formats numbers as currency. • UpperCasePipe: Converts text to uppercase. • LowerCasePipe: Converts text to lowercase. • PercentPipe: Formats numbers as percentages. • AsyncPipe: Unwraps a promise or observable and • updates the view when the data changes. Angular Pipes
walk through the process of creating a custom pipe step by step • Create a New Pipe: • Implement the Pipe Logic • Register the Pipe • Use the Custom Pipe Custom pipes can be powerful tools for transforming and formatting data directly in templates, but be mindful of performance considerations when using multiple pipes, especially in situations with frequent change detection. How to create custom Pipes
which is a popular platform for building web applications. Directives are used to extend the functionality of HTML elements and provide a way to create reusable components, manipulate the DOM (Document Object Model), and add custom behaviors to your application. There are three types of directives in Angular: • Component Directives: @Component • Attribute Directives: ngStyle & ngClass. • Structural Directives: ngIf, ngFor & ngSwitch Angular Directives
class, class members • These are prefix with @ symbol • Angular has built-In decorators like - @Component, @NgModule, @Directive, @Pipe etc. Class / Fields Decorator MetaData Decorate
for defining a module ▪ @Component – Used for defining a component ▪ @Directive – Used for defining a directive ▪ @Injectable – Used for injecting dependencies ▪ @Pipe – Used for defining a pipe 2. Class field decorators ▪ @Input – Used for receiving data (input) from parent to child component ▪ @Output – Used for passing data (events) from child to parent component
approach. It uses services for shared functionality, dependency injection for loose coupling, templates for data binding, and routing for single-page navigation.
to tap into different stages of a component's lifecycle. These hooks enable you to execute custom code at specific points. The main lifecycle hooks in Angular are: • ngOnChanges() • ngOnInit() • ngDoCheck() : Detect changes where ngOnChanges() wont catch them • ngAfterContentInit() • ngAfterContentChecked() • ngAfterViewInit() • ngAfterViewChecked() • ngOnDestroy Angular LIFECYCLE HOOKS
blocks of page views. Each component consists of a template (defining the UI), a class (containing the logic), and styles. Components encapsulate specific functionalities and can be organized into modules for modularity. They define the visual and interactive elements of a page, enabling the creation of dynamic and interactive web applications. <app-header></app-header> <router-outlet></router-outlet> <app-footer></app-footer>
Decorators are used to attach metadata to a class @Component({ selector: 'app-menu', template:<p>Name: {{name}}</p> <p><input type="text" value="{{name}}"</p>`, styles: [] }) export class MenuComponent implements OnInit { public name: string = 'Babar Shahzad'; constructor() { } } Component Decorators Directive / Selector Name used in HTML User views Data Binding
business logic, and communication tasks in Angular applications. They enable components to share data, centralize logic, and promote code reusability through dependency injection. Angular Services