npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-ui-router-uib-modal

v0.0.11

Published

AngularJS module that adds support for ui-bootstrap modal states when using ui-router.

Downloads

1,591

Readme

angular-ui-router-uib-modal

Build Status

AngularJS module that adds support for ui-bootstrap modal states when using ui-router.

Motivation

Some RIAs using UI-Router use modal dialogs for certain application states. The UI-Router's FAQ, shows how to implement modal dialogs using ui.bootstrap.modal service. While it works well, it requires a lot of boiler-plate code, complicates the state definition, and requires the state controller to be aware that its inside a $uibModalInstance to automatically close the dialog on a state change.

This module gets rid of the boilerplate by adding support for a modal: true option in state definitions. This causes the state to be displayed via $uibModal.open(...) instead of within a <ui-view/>.

Installing the Module

Installation can be done through bower or npm:

bower install angular-ui-router-uib-modal

In your page add:

  <script src="bower_components/angular-ui-router-uib-modal/angular-ui-router-uib-modal.js"></script>

Loading the Module

This module declares itself as ui.router.modal, so it can be declared as a dependency of your application as normal:

var app = angular.module('myApp', ['ng', 'ui.router', 'ui.bootstrap', 'ui.router.modal']);

Specifying modal states

Adding a modal: true to a state definition causes its template to be opened through a call to $uibModal.open(stateDefinition) rather than embedding it inside of a <ui-view/>.

To specify which resolved state values are available to the modal controller, use an array instead of true, e.g. modal: ['value1', 'value2'].

Inside the modal state controller, the modal via can be closed via $uibModalInstance.close/dismiss() or by transitioning to the parent state via $state.go('^').

$stateProvider
  .state('contacts', {
    url: '/contacts',
    // ...
  })
  .state('contacts.contact', {
    url: '/:contactId',
    modal: true,
    template: '<div class="modal-header">...',
    controller: function($scope, $state, contact) {
		$scope.close = function() {
			$state.go('^');
		}
    },
    resolve: {
      // Single contact
      contact: ['Contacts', '$stateParams', function(Contacts, $stateParams) {
        // Use Contacts service to retrieve a contact
        return Contacts.get({ id: $stateParams.contactId });
      }]
    }
  })

Caveats

Modal does not have access to parent state's $scope values

The modal's $scope doesn't inherit anything from the parent state's scope. So any data that comes from the parent should be specified via resolve settings.

You must specify resolved parent state values to provide to the modal controller

By default, $uibModal.open() is called with only the resolved values of the modal state. If you want to include values resolved in parent states, use an array instead of true for the modal setting.

In the following examples, $uibModal.open() for the parent.child state will be called with resolved values a, b, x, y and z.

$stateProvider
  .state('parent', {
    ...
    resolve: {
      a: ...,
      b: ...,
      c: ...
    }
  })
  .state('parent.child', {
    ...
    modal: ['a', 'b'],
    resolve: {
      x: ...,
      y: ...,
      z: ...
    }
  })

Does not work with old versions of UI-Bootstrap

The module uses the current $uibModal service rather than the deprecated $modal.

Does not work with custom onEnter and onExit state configurations

The module works by adding onEnter and onExit state configurations to modal states. If these are already defined in a modal state, an error is thrown.

Copyright & License

Copyright 2016 Stepan Riha. All Rights Reserved.

This may be redistributed under the MIT licence. For the full license terms, see the LICENSE file which should be alongside this readme.