angular-modal-service
Advanced tools
Comparing version 0.6.10 to 0.10.0
{ | ||
"name": "angular-modal-service", | ||
"version": "0.6.10", | ||
"version": "0.10.0", | ||
"homepage": "https://github.com/dwmkerr/angular-modal-service", | ||
@@ -32,12 +32,7 @@ "authors": [ | ||
"dependencies": { | ||
"angular": "~1.4.x" | ||
"angular": "~1.5.x" | ||
}, | ||
"devDependencies": { | ||
"angular-mocks": "~1.4.x", | ||
"bootstrap": "~3.3.2", | ||
"jquery": "~2.1.3" | ||
}, | ||
"resolutions": { | ||
"angular": "1.4.9" | ||
"angular-mocks": "~1.5.x" | ||
} | ||
} |
@@ -0,1 +1,7 @@ | ||
## v0.6.11 | ||
* Robustness for 'locationChangeEvent'. | ||
* Robustness if the body element changs. | ||
* Addded `bower` as a dev dependency. Run `bower install` as an `npm` `postinstall` step, which makes initial setup on a clean machine slightly easier. | ||
## v0.6.10 | ||
@@ -45,2 +51,2 @@ | ||
unspecified, the modal is added to the `body`, as before. | ||
Thanks [cointilt](https://github.com/cointilt)! | ||
Thanks [cointilt](https://github.com/cointilt)! |
@@ -1,164 +0,219 @@ | ||
// angularModalService.js | ||
// | ||
// Service for showing modal dialogs. | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
/***** JSLint Config *****/ | ||
/*global angular */ | ||
(function() { | ||
'use strict'; | ||
// angularModalService.js | ||
// | ||
// Service for showing modal dialogs. | ||
/***** JSLint Config *****/ | ||
/*global angular */ | ||
(function () { | ||
'use strict'; | ||
var module = angular.module('angularModalService', []); | ||
module.factory('ModalService', ['$animate', '$document', '$compile', '$controller', '$http', '$rootScope', '$q', '$templateRequest', '$timeout', function ($animate, $document, $compile, $controller, $http, $rootScope, $q, $templateRequest, $timeout) { | ||
function ModalService() { | ||
var self = this; | ||
// Returns a promise which gets the template, either | ||
// from the template parameter or via a request to the | ||
// template url parameter. | ||
var getTemplate = function getTemplate(template, templateUrl) { | ||
var deferred = $q.defer(); | ||
if (template) { | ||
deferred.resolve(template); | ||
} else if (templateUrl) { | ||
$templateRequest(templateUrl, true).then(function (template) { | ||
deferred.resolve(template); | ||
}, function (error) { | ||
deferred.reject(error); | ||
}); | ||
} else { | ||
deferred.reject("No template or templateUrl has been specified."); | ||
} | ||
return deferred.promise; | ||
}; | ||
// Adds an element to the DOM as the last child of its container | ||
// like append, but uses $animate to handle animations. Returns a | ||
// promise that is resolved once all animation is complete. | ||
var appendChild = function appendChild(parent, child) { | ||
var children = parent.children(); | ||
if (children.length > 0) { | ||
return $animate.enter(child, parent, children[children.length - 1]); | ||
} | ||
return $animate.enter(child, parent); | ||
}; | ||
self.showModal = function (options) { | ||
// Get the body of the document, we'll add the modal to this. | ||
var body = angular.element($document[0].body); | ||
// Create a deferred we'll resolve when the modal is ready. | ||
var deferred = $q.defer(); | ||
// Validate the input parameters. | ||
var controllerName = options.controller; | ||
if (!controllerName) { | ||
deferred.reject("No controller has been specified."); | ||
return deferred.promise; | ||
} | ||
// Get the actual html of the template. | ||
getTemplate(options.template, options.templateUrl).then(function (template) { | ||
// Create a new scope for the modal. | ||
var modalScope = (options.scope || $rootScope).$new(); | ||
var rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose); | ||
// Create the inputs object to the controller - this will include | ||
// the scope, as well as all inputs provided. | ||
// We will also create a deferred that is resolved with a provided | ||
// close function. The controller can then call 'close(result)'. | ||
// The controller can also provide a delay for closing - this is | ||
// helpful if there are closing animations which must finish first. | ||
var closeDeferred = $q.defer(); | ||
var closedDeferred = $q.defer(); | ||
var inputs = { | ||
$scope: modalScope, | ||
close: function close(result, delay) { | ||
if (delay === undefined || delay === null) delay = 0; | ||
$timeout(function () { | ||
cleanUpClose(result); | ||
}, delay); | ||
} | ||
}; | ||
// If we have provided any inputs, pass them to the controller. | ||
if (options.inputs) angular.extend(inputs, options.inputs); | ||
// Compile then link the template element, building the actual element. | ||
// Set the $element on the inputs so that it can be injected if required. | ||
var linkFn = $compile(template); | ||
var modalElement = linkFn(modalScope); | ||
inputs.$element = modalElement; | ||
// Create the controller, explicitly specifying the scope to use. | ||
var controllerObjBefore = modalScope[options.controllerAs]; | ||
var modalController = $controller(options.controller, inputs, false, options.controllerAs); | ||
if (options.controllerAs && controllerObjBefore) { | ||
angular.extend(modalController, controllerObjBefore); | ||
} | ||
// Finally, append the modal to the dom. | ||
if (options.appendElement) { | ||
// append to custom append element | ||
appendChild(options.appendElement, modalElement); | ||
} else { | ||
// append to body when no custom append element is specified | ||
appendChild(body, modalElement); | ||
} | ||
// We now have a modal object... | ||
var modal = { | ||
controller: modalController, | ||
scope: modalScope, | ||
element: modalElement, | ||
close: closeDeferred.promise, | ||
closed: closedDeferred.promise | ||
}; | ||
// ...which is passed to the caller via the promise. | ||
deferred.resolve(modal); | ||
function cleanUpClose(result) { | ||
// Resolve the 'close' promise. | ||
closeDeferred.resolve(result); | ||
// Let angular remove the element and wait for animations to finish. | ||
$animate.leave(modalElement).then(function () { | ||
// Resolve the 'closed' promise. | ||
closedDeferred.resolve(result); | ||
// We can now clean up the scope | ||
modalScope.$destroy(); | ||
// Unless we null out all of these objects we seem to suffer | ||
// from memory leaks, if anyone can explain why then I'd | ||
// be very interested to know. | ||
inputs.close = null; | ||
deferred = null; | ||
closeDeferred = null; | ||
modal = null; | ||
inputs = null; | ||
modalElement = null; | ||
modalScope = null; | ||
}); | ||
// remove event watcher | ||
rootScopeOnClose && rootScopeOnClose(); | ||
} | ||
}).then(null, function (error) { | ||
// 'catch' doesn't work in IE8. | ||
deferred.reject(error); | ||
}); | ||
return deferred.promise; | ||
}; | ||
} | ||
return new ModalService(); | ||
}]); | ||
})(); | ||
'use strict'; | ||
var module = angular.module('angularModalService', []); | ||
module.factory('ModalService', ['$animate', '$document', '$compile', '$controller', '$http', '$rootScope', '$q', '$templateRequest', '$timeout', | ||
function($animate, $document, $compile, $controller, $http, $rootScope, $q, $templateRequest, $timeout) { | ||
// Get the body of the document, we'll add the modal to this. | ||
var body = $document.find('body'); | ||
function ModalService() { | ||
var self = this; | ||
// Returns a promise which gets the template, either | ||
// from the template parameter or via a request to the | ||
// template url parameter. | ||
var getTemplate = function(template, templateUrl) { | ||
var deferred = $q.defer(); | ||
if (template) { | ||
deferred.resolve(template); | ||
} else if (templateUrl) { | ||
$templateRequest(templateUrl, true) | ||
.then(function(template) { | ||
deferred.resolve(template); | ||
}, function(error) { | ||
deferred.reject(error); | ||
}); | ||
} else { | ||
deferred.reject("No template or templateUrl has been specified."); | ||
} | ||
return deferred.promise; | ||
}; | ||
// Adds an element to the DOM as the last child of its container | ||
// like append, but uses $animate to handle animations. Returns a | ||
// promise that is resolved once all animation is complete. | ||
var appendChild = function(parent, child) { | ||
var children = parent.children(); | ||
if (children.length > 0) { | ||
return $animate.enter(child, parent, children[children.length - 1]); | ||
} | ||
return $animate.enter(child, parent); | ||
}; | ||
self.showModal = function(options) { | ||
// Create a deferred we'll resolve when the modal is ready. | ||
var deferred = $q.defer(); | ||
// Validate the input parameters. | ||
var controllerName = options.controller; | ||
if (!controllerName) { | ||
deferred.reject("No controller has been specified."); | ||
return deferred.promise; | ||
} | ||
// Get the actual html of the template. | ||
getTemplate(options.template, options.templateUrl) | ||
.then(function(template) { | ||
// Create a new scope for the modal. | ||
var modalScope = (options.scope || $rootScope).$new(); | ||
// Create the inputs object to the controller - this will include | ||
// the scope, as well as all inputs provided. | ||
// We will also create a deferred that is resolved with a provided | ||
// close function. The controller can then call 'close(result)'. | ||
// The controller can also provide a delay for closing - this is | ||
// helpful if there are closing animations which must finish first. | ||
var closeDeferred = $q.defer(); | ||
var closedDeferred = $q.defer(); | ||
var inputs = { | ||
$scope: modalScope, | ||
close: function(result, delay) { | ||
if (delay === undefined || delay === null) delay = 0; | ||
$timeout(function() { | ||
// Resolve the 'close' promise. | ||
closeDeferred.resolve(result); | ||
// Let angular remove the element and wait for animations to finish. | ||
$animate.leave(modalElement) | ||
.then(function () { | ||
// Resolve the 'closed' promise. | ||
closedDeferred.resolve(result); | ||
// We can now clean up the scope | ||
modalScope.$destroy(); | ||
// Unless we null out all of these objects we seem to suffer | ||
// from memory leaks, if anyone can explain why then I'd | ||
// be very interested to know. | ||
inputs.close = null; | ||
deferred = null; | ||
closeDeferred = null; | ||
modal = null; | ||
inputs = null; | ||
modalElement = null; | ||
modalScope = null; | ||
}); | ||
}, delay); | ||
} | ||
}; | ||
// If we have provided any inputs, pass them to the controller. | ||
if (options.inputs) angular.extend(inputs, options.inputs); | ||
// Compile then link the template element, building the actual element. | ||
// Set the $element on the inputs so that it can be injected if required. | ||
var linkFn = $compile(template); | ||
var modalElement = linkFn(modalScope); | ||
inputs.$element = modalElement; | ||
// Create the controller, explicitly specifying the scope to use. | ||
var controllerObjBefore = modalScope[options.controllerAs]; | ||
var modalController = $controller(options.controller, inputs, false, options.controllerAs); | ||
if (options.controllerAs && controllerObjBefore) { | ||
angular.extend(modalController, controllerObjBefore); | ||
} | ||
// Finally, append the modal to the dom. | ||
if (options.appendElement) { | ||
// append to custom append element | ||
appendChild(options.appendElement, modalElement); | ||
} else { | ||
// append to body when no custom append element is specified | ||
appendChild(body, modalElement); | ||
} | ||
// We now have a modal object... | ||
var modal = { | ||
controller: modalController, | ||
scope: modalScope, | ||
element: modalElement, | ||
close: closeDeferred.promise, | ||
closed: closedDeferred.promise | ||
}; | ||
// ...which is passed to the caller via the promise. | ||
deferred.resolve(modal); | ||
}) | ||
.then(null, function(error) { // 'catch' doesn't work in IE8. | ||
deferred.reject(error); | ||
}); | ||
return deferred.promise; | ||
}; | ||
} | ||
return new ModalService(); | ||
}]); | ||
}()); | ||
/***/ } | ||
/******/ ]); | ||
//# sourceMappingURL=angular-modal-service.js.map |
@@ -1,3 +0,2 @@ | ||
/*angular-modal-service v0.6.9 - https://github.com/dwmkerr/angular-modal-service */ | ||
!function(){"use strict";var e=angular.module("angularModalService",[]);e.factory("ModalService",["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(e,n,r,t,l,o,c,u,a){function i(){var n=this,l=function(e,n){var r=c.defer();return e?r.resolve(e):n?u(n,!0).then(function(e){r.resolve(e)},function(e){r.reject(e)}):r.reject("No template or templateUrl has been specified."),r.promise},i=function(n,r){var t=n.children();return t.length>0?e.enter(r,n,t[t.length-1]):e.enter(r,n)};n.showModal=function(n){var u=c.defer(),p=n.controller;return p?(l(n.template,n.templateUrl).then(function(l){var p=(n.scope||o).$new(),d=c.defer(),f=c.defer(),m={$scope:p,close:function(n,r){(void 0===r||null===r)&&(r=0),a(function(){d.resolve(n),e.leave($).then(function(){f.resolve(n),p.$destroy(),m.close=null,u=null,d=null,j=null,m=null,$=null,p=null})},r)}};n.inputs&&angular.extend(m,n.inputs);var v=r(l),$=v(p);m.$element=$;var h=p[n.controllerAs],g=t(n.controller,m,!1,n.controllerAs);n.controllerAs&&h&&angular.extend(g,h),n.appendElement?i(n.appendElement,$):i(s,$);var j={controller:g,scope:p,element:$,close:d.promise,closed:f.promise};u.resolve(j)}).then(null,function(e){u.reject(e)}),u.promise):(u.reject("No controller has been specified."),u.promise)}}var s=n.find("body");return new i}])}(); | ||
//# sourceMappingURL=angular-modal-service.min.js.map | ||
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n){"use strict";!function(){var e=angular.module("angularModalService",[]);e.factory("ModalService",["$animate","$document","$compile","$controller","$http","$rootScope","$q","$templateRequest","$timeout",function(e,n,t,r,o,l,c,u,a){function i(){var o=this,i=function(e,n){var t=c.defer();return e?t.resolve(e):n?u(n,!0).then(function(e){t.resolve(e)},function(e){t.reject(e)}):t.reject("No template or templateUrl has been specified."),t.promise},s=function(n,t){var r=n.children();return r.length>0?e.enter(t,n,r[r.length-1]):e.enter(t,n)};o.showModal=function(o){var u=angular.element(n[0].body),p=c.defer(),d=o.controller;return d?(i(o.template,o.templateUrl).then(function(n){function i(n){m.resolve(n),e.leave(g).then(function(){v.resolve(n),d.$destroy(),$.close=null,p=null,m=null,S=null,$=null,g=null,d=null}),f&&f()}var d=(o.scope||l).$new(),f=l.$on("$locationChangeSuccess",i),m=c.defer(),v=c.defer(),$={$scope:d,close:function(e,n){void 0!==n&&null!==n||(n=0),a(function(){i(e)},n)}};o.inputs&&angular.extend($,o.inputs);var h=t(n),g=h(d);$.$element=g;var x=d[o.controllerAs],j=r(o.controller,$,!1,o.controllerAs);o.controllerAs&&x&&angular.extend(j,x),o.appendElement?s(o.appendElement,g):s(u,g);var S={controller:j,scope:d,element:g,close:m.promise,closed:v.promise};p.resolve(S)}).then(null,function(e){p.reject(e)}),p.promise):(p.reject("No controller has been specified."),p.promise)}}return new i}])}()}]); | ||
//# sourceMappingURL=./dst/angular-modal-service.min.js.map |
{ | ||
"name": "angular-modal-service", | ||
"version": "0.6.10", | ||
"version": "0.10.0", | ||
"description": "AngularJS Service for showing Modals and Popups", | ||
"main": "./dst/angular-modal-service.js", | ||
"scripts": { | ||
"test": "gulp test", | ||
"test-debug": "./node_modules/.bin/karma start ./test/karma.config.js --no-single-run --browsers Chrome", | ||
"coveralls": "cp build/coverage/PhantomJS*/lcov.info lcov.info && node node_modules/coveralls/bin/coveralls.js < lcov.info" | ||
"build": "webpack && uglifyjs ./dst/angular-modal-service.js --compress --mangle -o ./dst/angular-modal-service.min.js --source-map ./dst/angular-modal-service.min.js.map", | ||
"start": "webpack-dev-server --inline --content-base ./samples", | ||
"test": "karma start karma.config.js", | ||
"test-debug": "karma start karma.config.js --no-single-run --browsers Chrome", | ||
"coveralls": "cp build/coverage/PhantomJS*/lcov.info lcov.info && node node_modules/coveralls/bin/coveralls.js < lcov.info", | ||
"postinstall": "bower install" | ||
}, | ||
@@ -28,23 +31,22 @@ "repository": { | ||
"devDependencies": { | ||
"connect-livereload": "^0.5.3", | ||
"babel-core": "^6.9.1", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.9.0", | ||
"bower": "^1.7.9", | ||
"coveralls": "^2.10.0", | ||
"express": "^4.12.0", | ||
"gulp": "^3.8.11", | ||
"gulp-header": "^1.2.2", | ||
"gulp-jshint": "^1.9.2", | ||
"gulp-open": "^1.0.0", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-sourcemaps": "^1.5.0", | ||
"gulp-uglify": "^1.1.0", | ||
"jasmine-core": "^2.4.1", | ||
"jshint-stylish": "^2.0.0", | ||
"karma": "^0.13.10", | ||
"karma-chrome-launcher": "^0.2.0", | ||
"karma-coverage": "^0.5.1", | ||
"karma-jasmine": "~0.3", | ||
"karma-junit-reporter": "~0.3", | ||
"karma-phantomjs-launcher": "^0.2.1", | ||
"opn": "^3.0.1", | ||
"phantomjs": "^1.9.18", | ||
"tiny-lr": "^0.1.5" | ||
"karma": "0.13.x", | ||
"karma-chrome-launcher": "1.0.x", | ||
"karma-coverage": "1.0.x", | ||
"karma-jasmine": "1.0.x", | ||
"karma-junit-reporter": "2.0.x", | ||
"karma-phantomjs-launcher": "1.0.x", | ||
"karma-webpack": "^1.7.0", | ||
"phantomjs": "2.1.x", | ||
"phantomjs-prebuilt": "2.1.x", | ||
"uglify-js": "^2.6.2", | ||
"webpack": "^1.13.1", | ||
"webpack-dev-server": "^1.14.1" | ||
} | ||
} |
@@ -19,18 +19,14 @@ angular-modal-service | ||
First, install with Bower: | ||
Install with Bower or NPM: | ||
``` | ||
bower install angular-modal-service | ||
``` | ||
or npm | ||
``` | ||
npm install angular-modal-service | ||
``` | ||
Then reference the minified script: | ||
```html | ||
<script src="bower_components\angular-modal-service\dst\angular-modal-service.min.js"></script> | ||
<script src="bower_components/angular-modal-service/dst/angular-modal-service.min.js"></script> | ||
<script src="./node_modules/angular-modal-service/dst/angular-modal-service.min.js"></script> | ||
``` | ||
@@ -216,7 +212,7 @@ | ||
npm install | ||
bower install | ||
gulp | ||
npm test | ||
npm start | ||
``` | ||
The samples will be opened in the browser. All JavaScript changes will re-run the tests, all samples changes are automatically reloaded into the browser. | ||
The dependencies will install, the tests will be run (always a useful sanity check after a clean checkout) and the code will run. You can open the browser at localhost:8080 to see the samples. As you change the code in the `src/` folder, it will be re-built and the browser will be updated. | ||
@@ -313,1 +309,3 @@ The easiest way to adapt the code is to play with some of the examples in the ``samples`` folder. | ||
* [maxdow](https://github.com/maxdow) - Added support for controller inlining. | ||
* [kernowjoe](https://github.com/kernowjoe) - Robustness around locationChange | ||
* [arthur-xavier](https://github.com/arthur-xavier) - Robustness when `body` element changes. |
@@ -16,5 +16,2 @@ // angularModalService.js | ||
// Get the body of the document, we'll add the modal to this. | ||
var body = $document.find('body'); | ||
function ModalService() { | ||
@@ -57,2 +54,5 @@ | ||
// Get the body of the document, we'll add the modal to this. | ||
var body = angular.element($document[0].body); | ||
// Create a deferred we'll resolve when the modal is ready. | ||
@@ -74,2 +74,3 @@ var deferred = $q.defer(); | ||
var modalScope = (options.scope || $rootScope).$new(); | ||
var rootScopeOnClose = $rootScope.$on('$locationChangeSuccess', cleanUpClose); | ||
@@ -89,25 +90,5 @@ // Create the inputs object to the controller - this will include | ||
$timeout(function() { | ||
// Resolve the 'close' promise. | ||
closeDeferred.resolve(result); | ||
// Let angular remove the element and wait for animations to finish. | ||
$animate.leave(modalElement) | ||
.then(function () { | ||
// Resolve the 'closed' promise. | ||
closedDeferred.resolve(result); | ||
cleanUpClose(result); | ||
// We can now clean up the scope | ||
modalScope.$destroy(); | ||
// Unless we null out all of these objects we seem to suffer | ||
// from memory leaks, if anyone can explain why then I'd | ||
// be very interested to know. | ||
inputs.close = null; | ||
deferred = null; | ||
closeDeferred = null; | ||
modal = null; | ||
inputs = null; | ||
modalElement = null; | ||
modalScope = null; | ||
}); | ||
}, delay); | ||
@@ -155,2 +136,32 @@ } | ||
function cleanUpClose(result) { | ||
// Resolve the 'close' promise. | ||
closeDeferred.resolve(result); | ||
// Let angular remove the element and wait for animations to finish. | ||
$animate.leave(modalElement) | ||
.then(function () { | ||
// Resolve the 'closed' promise. | ||
closedDeferred.resolve(result); | ||
// We can now clean up the scope | ||
modalScope.$destroy(); | ||
// Unless we null out all of these objects we seem to suffer | ||
// from memory leaks, if anyone can explain why then I'd | ||
// be very interested to know. | ||
inputs.close = null; | ||
deferred = null; | ||
closeDeferred = null; | ||
modal = null; | ||
inputs = null; | ||
modalElement = null; | ||
modalScope = null; | ||
}); | ||
// remove event watcher | ||
rootScopeOnClose && rootScopeOnClose(); | ||
} | ||
}) | ||
@@ -157,0 +168,0 @@ .then(null, function(error) { // 'catch' doesn't work in IE8. |
@@ -6,3 +6,3 @@ describe('basics', function() { | ||
beforeEach(function() { | ||
module('angularModalService'); | ||
angular.mock.module('angularModalService'); | ||
inject(function(_ModalService_) { | ||
@@ -9,0 +9,0 @@ ModalService = _ModalService_; |
@@ -28,3 +28,3 @@ describe('controller', function() { | ||
beforeEach(function() { | ||
module('controllertests'); | ||
angular.mock.module('controllertests'); | ||
inject(function(_ModalService_, $injector) { | ||
@@ -31,0 +31,0 @@ ModalService = _ModalService_; |
@@ -6,2 +6,3 @@ describe('dom', function() { | ||
var $timeout = null; | ||
var $rootScope = null; | ||
@@ -14,6 +15,7 @@ angular.module('domtests', ['angularModalService']) | ||
beforeEach(function() { | ||
module('domtests'); | ||
inject(function(_ModalService_, $injector) { | ||
angular.mock.module('domtests'); | ||
inject(function(_ModalService_, _$rootScope_, $injector) { | ||
ModalService = _ModalService_; | ||
$httpBackend = $injector.get('$httpBackend'); | ||
$rootScope = _$rootScope_; | ||
$timeout = $injector.get('$timeout'); | ||
@@ -123,2 +125,26 @@ $httpBackend.when('GET', 'some/template1.html').respond("<div id='template1'>template1</div>"); | ||
it('should remove the template html from the dom when the $locationChangeSuccess event is fired', function() { | ||
$httpBackend.expectGET('some/template2.html'); | ||
ModalService.showModal({ | ||
controller: "DomController", | ||
templateUrl: "some/template2.html" | ||
}).then(function(modal) { | ||
// We should be able to find the element that has been created in the dom. | ||
expect(document.getElementById('template2')).not.toBeNull(); | ||
modal.close.then(function(result) { | ||
expect(document.getElementById('template2')).toBeNull(); | ||
}); | ||
$rootScope.$emit('$locationChangeSuccess'); | ||
}); | ||
$httpBackend.flush(); | ||
$timeout.flush(); | ||
}); | ||
}); |
@@ -13,3 +13,3 @@ describe('parameters', function() { | ||
beforeEach(function() { | ||
module('parametertests'); | ||
angular.mock.module('parametertests'); | ||
inject(function(_ModalService_, $rootScope) { | ||
@@ -16,0 +16,0 @@ ModalService = _ModalService_; |
@@ -12,3 +12,3 @@ describe('template', function() { | ||
beforeEach(function() { | ||
module('templatetests'); | ||
angular.mock.module('templatetests'); | ||
inject(function(_ModalService_, $rootScope, $injector) { | ||
@@ -15,0 +15,0 @@ ModalService = _ModalService_; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
19
1
80069
30
1047
309
1