Book Image

Accelerating Angular Development with Ivy

By : Lars Gyrup Brink Nielsen, Mateus Carniatto, Jacob Andresen
Book Image

Accelerating Angular Development with Ivy

By: Lars Gyrup Brink Nielsen, Mateus Carniatto, Jacob Andresen

Overview of this book

Angular Ivy is the latest rendering engine and compiler introduced in Angular. Ivy helps frontend developers to make their Angular applications faster, better optimized, and more robust. This easy-to-follow guide will help you get to grips with the new features of Angular Ivy and show you how to migrate your Angular apps from View Engine to Ivy. You'll begin by learning about the most popular features of Angular Ivy with the help of simple stand-alone examples and realize its capabilities by working on a real-world application project. You'll then discover strategies to improve your developer workflow through new debugging APIs, testing APIs, and configurations that support higher code quality and productive development features. Throughout the book, you'll explore essential components of Angular, such as Angular Component Dev Kit (CDK), Ahead-of-time (AOT) compilation, and Angular command line interface (CLI). Finally, you'll gain a clear understanding of these components along with Angular Ivy which will help you update your Angular applications with modern features. By the end of this Angular Ivy book, you will learn about the core features of Angular Ivy, discover how to migrate your Angular View Engine application, and find out how to set up a high-quality Angular Ivy project.
Table of Contents (14 chapters)

Inspecting an embedded view context

A structural directive is used to add and remove elements to the DOM throughout the lifecycle of a component. They create an embedded view, which is bound to a view context. This is the case of the NgIf and NgFor directives that are part of the Angular framework.

Important Note

Only one structural directive can be attached to an element. If you need to apply multiple structural directives, wrap the element in the special <ng-container> element, attach the outer structural directive to this element, and so on.

When we pass an element with a structural directive attached to ng.getContext, it returns the view context. For example, when we pass an element with an NgIf directive attached to it, NgIfContext is returned, which has the following shape:

interface NgIfContext {
  $implicit: boolean;
  ngIf: boolean;
}

The embedded view that is dynamically created by NgIf is bound to the $implicit property of NgIfContext...