Angular base class for if-like directives (show or hide under condition)
✓ Published0🌍 Public
TTomStanczyk
Last edited Aug 28, 2020
Created on Aug 28, 2020
This example demonstrates an abstract base class in Angular for building custom structural directives that show or hide template content under a condition. The code defines `AppBaseIfDirective`, which uses `ViewContainerRef` and `TemplateRef` to manage embedded views, along with protected methods `showView`, `hideView`, and `updateView` that toggle the view’s visibility. It provides reusable logic for if-like directives without binding to any specific data source. The implementation relies solely on Angular’s core APIs, with no external rendering libraries involved.
AI-generated description