Giter VIP home page Giter VIP logo

ngmodal's Introduction

ngModal

ngModal is very simple Angular.js modal dialog directive.

ngModal Screenshot

Download

You can also install the package using Bower.

bower install ngModal

Or add it to your bower.json file:

dependencies: {
  "ngModal": "~1.2.0"
}

The Basics

To use the library, add the JS file and CSS file, and then include the module in your app:

app = angular.module("myApp", ["ngModal"])

The directive itself is called modal-dialog. The only required attribute is show, which should reference a boolean variable that controls whether or not the dialog is shown. Inside, you can put whatever HTML content you'd like.

<modal-dialog show='dialogShown' dialog-title='My Dialog'>
  <p>Dialog content goes in here</p>
</modal-dialog>

Inline Options

There are a few options that be configured inline with attributes.

Option Default Description
dialog-title null Title placed in the header of the modal dialog.
width 50% Width of the dialog. Can be specified in px or %.
height 50% Height of the dialog. Can be specified in px or %.
on-close null Call a function when the dialog is closed. Ex: on-close='foo()'

Example:

<modal-dialog show='dialogShown' dialog-title='My Dialog' height='400px' width='75%'>
  <p>Dialog content goes in here</p>
</modal-dialog>

Configuration Options

You can also pre-configure some options during your app's configuration phase.

app.config(function(ngModalDefaultsProvider) {
  ngModalDefaultsProvider.set('option', 'value');
  // Or with a hash
  ngModalDefaultsProvider.set({option: 'value', option2: 'value2'});
})
Option Default Description
closeButtonHtml 'X' By default, the close button is just an X character. But you can set it to any HTML. For example, if you're using font-awesome, you could set it to <i class='fa fa-times'></i>

Browser Support

So far, it has only been tested in Chrome. There is some CSS that is not compatible with with older browsers, including IE9.

Contributing

Contributions are welcome. Whenever possible, please include test coverage with your contribution.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

To get the project running, you'll need NPM and Bower. Run npm install and bower install to install all dependencies. Then run grunt in the project directory to watch and compile changes. And you can run karma start to watch for changes and auto-execute unit tests.

Potential Features Down the Road

  • Ability to integrate easily with UI-Router. This may be possible already, but it needs to be explored.

ngmodal's People

Contributors

adamalbrecht avatar

Watchers

James Cloos avatar Michel Uncini 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.