Code Monkey home page Code Monkey logo

angular2-modal's Introduction

Angular 2: Bootstrap Modal/Dialog window.

DISCLAIMER

Angular 2 is still in the works. The core concepts are solid, but the API may change. If you find that a code snippet that does not work, please message me, and I will update.

Built with angular 2 Beta

Features:

  • Bootstrap model size configurable.
  • Select cancel/quit key.
  • Cascading.
  • Element blocking.
  • Blocking / Non blocking modal.
  • Modal as a component, replace the content by supplying a custom component.

Click for the Demo Click for the auto generated Docs

Blog post will be up soon! look for it in my Blog

See src/demo for demo app with examples.

Will try to add documented examples if time allows.

Known issue - DI exception:

If you encounter a version of the following exception:

EXCEPTION: No provider for XXXXX! (YYYYY -> XXXXX)

Where YYYYY will usually be a directive you've injected to a custom modal component you've built.

This is an error raised by angular core because it can't find a resolved providers for injectable tokens request by the directive/s you want to use within your component. These providers are common runtime objects that angular should know how to fetch, even if not defined. There is a bug opend here angular/angular#4330.

To workaround this issue supply these values in the resolved bindings array sent as a parameter to "open" or "openInside" calls.

let bindings = Injector.resolve([
            provide(IterableDiffers, {useValue: this.injector.get(IterableDiffers)}),
            provide(KeyValueDiffers, {useValue: this.injector.get(KeyValueDiffers)}),
            provide(Renderer, {useValue: this.injector.get(Renderer)})
        ]);
               
let dialog = modal.openInside(..., ..., ..., bindings, ...);

click for example

Another workaround that might work is to supply the resolved providers as part of the bootstrap process. I'm not sure it will work as it depends on the life cycle logic of the injected values which I don't know deeply enough. If you got it to work let me know.

Installation

    npm install angular2-modal --save

Running locally

git clone https://github.com/shlomiassaf/angular2-modal.git  
npm install  
typings install  
webpack-dev-server // development, webpack -p to build.  
browse to localhost:3000  

You can apply custom modals based on components.

Publishing

Publishing is done using the TypeScript compiler directly (no webpack) The process involves compiling into a directory called dist Webpack is using the build directory. Since I didn't find a way to instruct tsc what config file to use (i.e: a different tsconfig.json) I created a publish directory instead and set the --project argument accordingly.

Issues and TODO's

Animation

Not so complicated but not in angular 2 at the moment.

Module

Set webpack do build angular2-module.js as an initial webpack module (currently its not...) This will allow using it as an input for other projects.

Minimize DOM interaction

Reduce manual DOM interaction, do more usage of host object in @Component. Append child to the DOM using the angular 2 way, if you know tell me.

Allow Element blocking modal to be set on any element.

Currently blocking an element requires it to have an angular template variable placed in one of his children. This is due to the current angular implementation, as I see it. I have yet to find an angular way of inserting a compiled element to a native element/component without effecting it. See issue 6071

Bootstrap free / ShadowDOM

Make it fly solo....

Support for custom backdrops.

angular2-modal's People

Contributors

rushimusmaximus avatar shlomiassaf avatar

Watchers

 avatar  avatar

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.