-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefreshiframe.js
More file actions
32 lines (25 loc) · 963 Bytes
/
refreshiframe.js
File metadata and controls
32 lines (25 loc) · 963 Bytes
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
//Attach directive to iframe element, add the attribute refreshframe to flag the directive whenever you want to reset the src attribute of the iframe
(function () {
'use strict';
angular.module('app').directive('refreshiframe', [function () {
function link($scope, $element, $attr) {
setUpWatch();
function setUpWatch() {
$scope.$watch('refreshframe', function (newValue, oldValue) {
if (newValue) {
$element.attr('src', $element.attr('src'));
//this tells the directive not to reset the src attribute again on the iframe input element
$scope.refreshframe = false;
}
});
}
}
return {
link: link,
restrict: 'A',
scope: {
refreshframe: '='
}
}
}]);
})();