Skip to content

Commit

Permalink
Reverted custom scope functionality and re-order or link/controller s…
Browse files Browse the repository at this point in the history
…tep.
  • Loading branch information
dwmkerr committed Mar 16, 2015
1 parent fa87918 commit eb439f3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.6.5

* Reverted changes below as they led to a bug with injected `$element` in modal controller.
Added a test to protect against this case in the future.

## v0.6.4

* Merged `scope` option field. Updated readme.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ The `showModal` function takes an object with these fields:
* `inputs`: A set of values to pass as inputs to the controller. Each value provided
is injected into the controller constructor.
* `appendElement`: The custom angular element to append the modal to instead of default `body` element.
* `scope`: Optional. If provided, a new scope will not be created for the model - this scope will be used. Be aware that the modal service will *still* destroy the scope when the modal is closed. Typically you should not need to use this field, as the generated scope will handle most use cases.

#### The Modal Object

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-modal-service",
"version": "0.6.4",
"version": "0.6.5",
"homepage": "https://github.com/dwmkerr/angular-modal-service",
"authors": [
"Dave Kerr (github.com/dwmkerr)"
Expand Down
2 changes: 1 addition & 1 deletion dst/angular-modal-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
.then(function(template) {

// Create a new scope for the modal.
var modalScope = options.scope || $rootScope.$new();
var modalScope = $rootScope.$new();

// Create the inputs object to the controller - this will include
// the scope, as well as all inputs provided.
Expand Down
2 changes: 1 addition & 1 deletion dst/angular-modal-service.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dst/angular-modal-service.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-modal-service",
"version": "0.6.4",
"version": "0.6.5",
"description": "AngularJS Service for showing Modals and Popups",
"main": "./dst/angular-modal-service.js",
"scripts": {
Expand Down
21 changes: 21 additions & 0 deletions test/controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe('controller', function() {
})
.controller('ControllerAsController', function() {
this.character = "Fry";
})
.controller('ElementController', function($scope, $element) {
$scope.getElement = function() { return $element; };
});

beforeEach(function() {
Expand Down Expand Up @@ -97,4 +100,22 @@ describe('controller', function() {

});

it('should inject the modal element into the controller', function() {

$httpBackend.expectGET('some/controllertemplate.html');

ModalService.showModal({
controller: 'ElementController',
templateUrl: 'some/controllertemplate.html'
}).then(function(modal) {

// The controller should be on the scope.
expect(modal.scope.getElement()).not.toBeUndefined();

});

$httpBackend.flush();

});

});

0 comments on commit eb439f3

Please sign in to comment.