javascript - How do I get a webcam working with AngularJS? -


previously i've put working webcam code application , it's not working when updated angularjs v1.5.0. using webcam-directive working v1.3.0.

here code:

<webcam placeholder="selfieplaceholder"   on-stream="onstream(stream)"   on-access-denied="onerror(err)" on-streaming="onsuccess(video)"> </webcam> 

but it's giving following error angularjs v1.5.0:

uncaught error: [$parse:isecdom] referencing dom nodes in angular expressions disallowed! expression: onsuccess(video) http://errors.angularjs.org/1.5.0/$parse/isecdom?p0=onsuccess(video)

i tried used different solution angularjs ng-camera demo page not working me.

note: know issue can't access dom newer version of angularjs, same code works older version. need know how pass "video" dom object controller.

i've found solution of problem: 2 thing need done :

first in html:

<webcam channel="channel"          on-streaming="onsuccess()"          on-error="onerror(err)"          on-stream="onstream(stream)"></webcam> 

second in controller, can access dom video:

 $scope.onsuccess = function () {         // video element contains captured camera data         _video = $scope.channel.video;         $scope.$apply(function() {             $scope.patopts.w = _video.width;             $scope.patopts.h = _video.height;             //$scope.showdemos = true;         });     }; 

here working working example..


Comments