Angularjs - use $watch on an element with no ng-model -
i trying recaptcha working (cleany) angularjs.
the recaptcha being created in directive. callback function, trying $watch changes in inputs (recaptcha_challenge_field, recaptcha_response_field)
i can pass values scope :
scope.recaptcha_challenge_field = "value_taken_from_input_after_creation"
my problem recaptcha code being created without me can not add ng-model inputs. when
scope.$watch('recaptcha_response_field', function(newvalue, oldvalue) { console.log('recaptcha_response_field ' + newvalue); });
nothing happens because scope.recaptcha_challenge_field not linked
<input name="recaptcha_response_field" id="recaptcha_response_field" type="text">
my ideas :
- add dynamically ng-model inputs can't figure 1 out
- bind values input element , watch them
open suggestion.
thanks
without knowing recapthca library using, can shoot in dark. is
- get
var recaptchaelement = angular.element(...)
reference recaptcha - add ng-model text input using
.attr('ng-model', 'myprop')
- call $compile on element angular knows it:
$compile(recaptchaelement)(scope)
ideally should in directive. if make http://plnkr.co/ can more.
Comments
Post a Comment