-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathmodal.js
33 lines (31 loc) · 1010 Bytes
/
modal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
angular.module('angularify.semantic.modal', [])
.directive('modal', function () {
return {
restrict: 'E',
replace: true,
transclude: true,
require: 'ngModel',
template: '<div class="ui modal" ng-transclude></div>',
link: function (scope, element, attrs, ngModel) {
var options = {
onHide: function () {
ngModel.$setViewValue(false);
}
};
if (scope.additionalOptions != undefined) {
for (var attrname in scope.additionalOptions) { options[attrname] = scope.additionalOptions[attrname]; }
}
element.modal(options);
scope.$watch(function () {
return ngModel.$modelValue;
}, function (modelValue){
element.modal(modelValue ? 'show' : 'hide');
});
scope.$on('$destroy', function() {
element.modal('hide');
element.remove();
});
}
}
});