Giter Site home page Giter Site logo

mainawycliffe / ng-cdk-overlay-demo Goto Github PK

View Code? Open in Web Editor NEW
34.0 3.0 23.0 1.65 MB

How to build a reusable Modal Overlay/Dialog Using Angular CDK

Home Page: https://codinglatte.com/posts/angular/reusable-modal-overlay-using-angular-cdk-overlay/

JavaScript 8.61% TypeScript 70.05% HTML 20.35% CSS 0.98%
angular typescript angular-cdk angular-material2 bulma-css bulma angular8

ng-cdk-overlay-demo's Introduction

How to build a reusable Modal Overlay/Dialog Using Angular CDK

Demo

You can find the demo for this repo here and the accompanying article here.

ng-cdk-overlay-demo's People

Contributors

mainawycliffe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ng-cdk-overlay-demo's Issues

incompatiblity with types of ngTemplateOutlet ngComponentOutlet

Hi there! I wanna use this great solution but in angular 12 i have a 2 errors which is related with types of directives *ngTemplateOutlet and *ngComponentOutlet. The issue happens in overlay.component.html when angular compile. How we can fix it for new version of angular?

overlay.component.html

<ng-container [ngSwitch]="contentType">
        <ng-container *ngSwitchCase="'string'">
            <div class="box">
                <div [innerHTML]="content"></div>
            </div>
        </ng-container>

        <ng-container *ngSwitchCase="'template'">
            <ng-container ***ngTemplateOutlet="content; context: context"**></ng-container>
        </ng-container>

        <ng-container *ngSwitchCase="'component'">
            <ng-container ***ngComponentOutlet="content"**></ng-container>
        </ng-container>
    </ng-container>

variables in overlay.component.ts

contentType: 'template' | 'string' | 'component' = 'component';
content: string | TemplateRef<any> | Type<any>;
context;

errors
Type 'string | TemplateRef | Type' is not assignable to type 'TemplateRef | null'.
Type 'string' is not assignable to type 'TemplateRef | null'.

         <ng-container *ngTemplateOutlet="content; context: context"></ng-container>
                         ~~~~~~~~~~~~~~~~

Type 'string | TemplateRef | Type' is not assignable to type 'Type'.
Type 'string' is not assignable to type 'Type'.

         <ng-container *ngComponentOutlet="content"></ng-container>
                        ~~~~~~~~~~~~~~~~~

Overlay does not open

Greetings,

I am trying to implement your Overlay Service in my project. Unfortunately, I am unable to open the overlay from my button click event handler. Most likely, I missed a step in your instructions. If you have time, I would appreciate if you could look over my code and let me know what I am doing wrong.

My code is here.

Feel free to leave any suggestions you may have here.

Thanks!

PortalInjector is depreciated

Thanks for this nice library but in angular version 10.1.2 the PortalInjector is depreciated I tried fixing it using this method in the overlay.service.ts

createInjector(ref: MyOverlayRef, inj: Injector) {
    return Injector.create({parent: this.injector, providers: [{provide: MyOverlayRef, useValue: ref}]});
  }

It compiles but in the overlay.component.html the *ngSwitchCase directives are not recognized apparently dynamically creating component does not include CommonModule from @angular/common. I don't know what to try next any ideas on how to update it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.