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 :

  1. add dynamically ng-model inputs can't figure 1 out
  2. bind values input element , watch them

open suggestion.

thanks

without knowing recapthca library using, can shoot in dark. is

  1. get var recaptchaelement = angular.element(...) reference recaptcha
  2. add ng-model text input using .attr('ng-model', 'myprop')
  3. call $compile on element angular knows it: $compile(recaptchaelement)(scope)

ideally should in directive. if make http://plnkr.co/ can more.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -