├── .eslintrc.json ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── angular-ui-router-uib-modal.js ├── bower.json ├── build.txt ├── files.conf.js ├── gulpfile.js ├── index.d.ts ├── karma.conf.js ├── package.json ├── sample ├── app │ ├── app.js │ └── contacts │ │ ├── contacts-service.js │ │ ├── contacts.detail.html │ │ ├── contacts.detail.item.edit.html │ │ ├── contacts.detail.item.html │ │ ├── contacts.html │ │ ├── contacts.js │ │ └── contacts.list.html ├── assets │ └── contacts.json ├── common │ └── utils │ │ └── utils-service.js ├── css │ └── styles.css └── index.html ├── src └── angular-ui-router-uib-modal.ts ├── test └── angular-ui-router-modal.spec.ts ├── tsconfig.json └── tslint.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "browser": true 5 | }, 6 | "rules": { 7 | "no-console": "error", 8 | "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], 9 | "semi": ["error", "always"], 10 | "block-scoped-var": "error", 11 | "eqeqeq": "error", 12 | "brace-style": ["error", "1tbs", { "allowSingleLine": true }], 13 | "space-before-function-paren": ["error", "never"], 14 | "space-in-parens": ["error", "never"], 15 | "comma-spacing": ["error", { "before": false, "after": true }] 16 | } 17 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | src/**/*.js 35 | test/**/*.js 36 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "iojs" 4 | before_script: 5 | - export DISPLAY=:99.0 6 | - sh -e /etc/init.d/xvfb start 7 | - npm install -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Stepan Riha 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angular-ui-router-uib-modal 2 | =========================== 3 | 4 | [![Build Status](https://travis-ci.org/nonplus/angular-ui-router-uib-modal.svg?branch=master)](https://travis-ci.org/nonplus/angular-ui-router-uib-modal) 5 | 6 | AngularJS module that adds support for ui-bootstrap modal states when using ui-router. 7 | 8 | Motivation 9 | ---------- 10 | 11 | Some RIAs using UI-Router use modal dialogs for certain application states. 12 | The [UI-Router's FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state), 13 | shows how to implement modal dialogs using [ui.bootstrap.modal](http://angular-ui.github.io/bootstrap/#/modal) service. 14 | While it works well, it requires a lot of boiler-plate code, complicates the state definition, and requires the state 15 | controller to be aware that its inside a `$uibModalInstance` to automatically close the dialog on a state change. 16 | 17 | This module gets rid of the boilerplate by adding support for a `modal: true` option in state definitions. 18 | This causes the state to be displayed via `$uibModal.open(...)` instead of within a ``. 19 | 20 | Installing the Module 21 | --------------------- 22 | Installation can be done through bower or npm: 23 | ``` shell 24 | bower install angular-ui-router-uib-modal 25 | ``` 26 | 27 | In your page add: 28 | ```html 29 | 30 | ``` 31 | 32 | Loading the Module 33 | ------------------ 34 | 35 | This module declares itself as `ui.router.modal`, so it can be declared as a dependency of your application as normal: 36 | 37 | ```javascript 38 | var app = angular.module('myApp', ['ng', 'ui.router', 'ui.bootstrap', 'ui.router.modal']); 39 | ``` 40 | 41 | Specifying modal states 42 | ----------------------- 43 | 44 | Adding a `modal: true` to a state definition causes its template to be opened through a call to 45 | `$uibModal.open(stateDefinition)` rather than embedding it inside of a ``. 46 | 47 | To specify which resolved state values are available to the modal controller, use an array instead of `true`, 48 | e.g. `modal: ['value1', 'value2']`. 49 | 50 | Inside the modal state controller, the modal via can be closed via `$uibModalInstance.close/dismiss()` or by 51 | transitioning to the parent state via `$state.go('^')`. 52 | 53 | 54 | ```javascript 55 | $stateProvider 56 | .state('contacts', { 57 | url: '/contacts', 58 | // ... 59 | }) 60 | .state('contacts.contact', { 61 | url: '/:contactId', 62 | modal: true, 63 | template: '