Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Added callback function attribute to call outside of the directive to return image data #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions app/angular/directive.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* global Webcam */
(function(angular) {
(function(window, angular, undefined) {
'use strict';

angular
.module('camera')
.module('camera',[])
.directive('ngCamera', directive);

directive.$inject = ['$q', '$timeout'];
Expand All @@ -26,7 +26,8 @@
'cropWidth': '@',
'imageFormat': '@',
'jpegQuality': '@',
'snapshot': '='
'snapshot': '=',
'callback':'='
},
// 'templateUrl': '/angular/ng-camera.html',
'template': ['<div class="ng-camera">',
Expand Down Expand Up @@ -169,6 +170,10 @@

Webcam.snap(function(data_uri) {
scope.snapshot = data_uri;
console.log('image captured');
if(scope.callback!==undefined){
scope.callback(scope.snapshot)
}
});
});
} else {
Expand All @@ -178,6 +183,10 @@

Webcam.snap(function(data_uri) {
scope.snapshot = data_uri;
console.log('image captured');
if(scope.callback!==undefined){
scope.callback(scope.snapshot)
}
});
}
};
Expand All @@ -188,4 +197,4 @@
}
}

})(angular);
})(window, angular);