Skip to content

AntonioCardenas/ngviewcontainerref

Repository files navigation

Project: Angular 20 Dynamic Components

Overview

This project demonstrates the new features in Angular 20 for creating dynamic components, as described in the user's prompt. It will showcase the simplified and declarative approach using ViewContainerRef and the bindings property.

Features

  • Dynamic Component Creation: A DialogComponent will be created dynamically when a button is clicked.
  • inputBinding: The DialogComponent will receive data from the AppComponent using inputBinding.
  • outputBinding: The DialogComponent will emit an event that the AppComponent will listen to using outputBinding.
  • Unified and Declarative: The code will follow the new declarative style, avoiding manual subscriptions and setInput().

Plan

  1. Phase 1: Project Setup and Dialog Component

    • Create a new Angular application.
    • Create a DialogComponent with isOpen and title inputs, and a onClose output.
    • Style the DialogComponent to look like a modal dialog.
    • Update the AppComponent to include a button to create the dynamic component and a container for it.
  2. Phase 2: Dynamic Creation with Bindings

    • Implement the createDynamic() method in AppComponent.
    • Use viewChild to get a reference to the ViewContainerRef.
    • Use createComponent with inputBinding to pass isOpen and title to the DialogComponent.
    • Use outputBinding to handle the onClose event from the DialogComponent and remove the component.
  3. Phase 3: Final Touches and Verification

    • Ensure the application builds without errors.
    • Verify the dynamic component is created and destroyed correctly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages