From 46dcacaa7bcdfabe5c88a8b4b4617ed390325904 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 3 Mar 2016 23:03:10 +0300 Subject: [PATCH 1/3] Added callback function attribute to call outside of the directive Outer callback specified to return image data right after capturing to avoid explicit watcher on model in controllers where used this directive. In my case it's done to get image data and allow to store them in array of captured images outside the directive. also updated to run with angular 1.5 because in previous version i got error, can't load module. --- app/angular/directive.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/angular/directive.js b/app/angular/directive.js index 9b030b5..f2aabf6 100644 --- a/app/angular/directive.js +++ b/app/angular/directive.js @@ -1,9 +1,9 @@ /* global Webcam */ -(function(angular) { +(function() { 'use strict'; angular - .module('camera') + .module('camera',[]) .directive('ngCamera', directive); directive.$inject = ['$q', '$timeout']; @@ -26,7 +26,8 @@ 'cropWidth': '@', 'imageFormat': '@', 'jpegQuality': '@', - 'snapshot': '=' + 'snapshot': '=', + 'callback':'=' }, // 'templateUrl': '/angular/ng-camera.html', 'template': ['
', @@ -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 { @@ -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) + } }); } }; @@ -188,4 +197,4 @@ } } -})(angular); +})(); From 4bcf5f9f5b8a6a3c5063e2207c7b560e9410214f Mon Sep 17 00:00:00 2001 From: Mikhail Date: Fri, 4 Mar 2016 22:49:32 +0300 Subject: [PATCH 2/3] reupdated IIFE --- app/angular/directive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/angular/directive.js b/app/angular/directive.js index f2aabf6..868dba5 100644 --- a/app/angular/directive.js +++ b/app/angular/directive.js @@ -1,5 +1,5 @@ /* global Webcam */ -(function() { +(function(angular, window, undefined) { 'use strict'; angular @@ -197,4 +197,4 @@ } } -})(); +})(angular,window); From a4572e37794be340ecbf15d791e08c902c1fca47 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Fri, 4 Mar 2016 22:50:48 +0300 Subject: [PATCH 3/3] Update directive.js --- app/angular/directive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/angular/directive.js b/app/angular/directive.js index 868dba5..acbb5bc 100644 --- a/app/angular/directive.js +++ b/app/angular/directive.js @@ -1,5 +1,5 @@ /* global Webcam */ -(function(angular, window, undefined) { +(function(window, angular, undefined) { 'use strict'; angular @@ -197,4 +197,4 @@ } } -})(angular,window); +})(window, angular);