How To Add Ng-change Handler Dynamically To Input
the above code couldn't run, but can tell the problem. I want to add ng-change to input dynamically for some reason and after some search I found $compile could do this. But it se
Solution 1:
I think the problem is that you are compiling the text-form
element (given by the directive), but you append the ng-change attribute to the .form-control
element (which is not even a child of your directive). So angular is not aware of this and does not integrate the ng-change properly.
I think you should use this directive on the element you want to control this way, i.e.:
<input text-form type="{{type||'text'}}" name="{{name}}"class="form-control" ng-model="model">
and make the directive restrict to 'A' or 'AE'
Not sure, but I think it would also work if your directive is placed on a parent (e.g. the form element).
Post a Comment for "How To Add Ng-change Handler Dynamically To Input"