Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ bower install angular-modal

[Plunker demo](http://plnkr.co/edit/lJDNqafSCKdpMI8AjR0B?p=preview)

[Plunker demo (with animations)](http://plnkr.co/edit/EymZrEhiWa4zvXiA37qL?p=preview)

### Typical Use

> app.js
Expand Down Expand Up @@ -63,6 +65,41 @@ controller('MyCtrl', function (myModal) {
</div>
```

### Animations

With Angular 1.2, ngAnimate needs to be loaded as a separate module and injected as a dependency. Upon modal ```activate``` and ```deactivate```, animation css classes are automatically added to the element.

> app.js

```javascript
angular.module('myApp', ['btford.modal', 'ngAnimate']).
// ...
```

> modal.css

```css
// ...
.btf-modal.ng-enter {
transition: 1s linear all;
opacity: 0;
}
.btf-modal.ng-enter.ng-enter-active {
opacity: 1;
}
.btf-modal.ng-leave {
transition: 1s linear all;
opacity: 1;
}
.btf-modal.ng-leave.ng-leave-active {
transition: 1s linear all;
opacity: 0;
}
```

**Note:** the container in which the element is attached to must be under ng-app where ngAnimate is injected.


### Cleaning up

If you add any listeners within the modal's controller that are **outside the modal's `scope`**,
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",
"version": "0.4.0",
"version": "0.4.1",
"main": "modal.js",
"ignore": [
"**/.*",
Expand Down
6 changes: 3 additions & 3 deletions modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ factory('btfModal', function ($animate, $compile, $rootScope, $controller, $q, $
function attach (html, locals) {
element = angular.element(html);
if (element.length === 0) {
throw new Error('The template contains no elements; you need to wrap text nodes')
throw new Error('The template contains no elements; you need to wrap text nodes');
}
$animate.enter(element, container);
scope = $rootScope.$new();
if (locals) {
for (var prop in locals) {
Expand All @@ -59,7 +58,8 @@ factory('btfModal', function ($animate, $compile, $rootScope, $controller, $q, $
if (controllerAs) {
scope[controllerAs] = ctrl;
}
$compile(element)(scope);
$compile(element)(scope)
$animate.enter(element, container);
}

function deactivate () {
Expand Down
3 changes: 2 additions & 1 deletion modal.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 modal.min.js.map

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

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",
"version": "0.4.0",
"version": "0.4.1",
"description": "easily add a modal to your angular app",
"main": "modal.js",
"scripts": {
Expand Down