javascript - How to get the value of a field with ng-change -
i know how react user input in textarea ng-change in angularjs. how can current input inside angular controller? missing $(this).value();
in jquery.
<script> angular.module('changeexample', []) .controller('examplecontroller', ['$scope', function($scope) { $scope.evaluatechange = function() { console.log("how current content of field?"); }; }]); </script> <div ng-controller="examplecontroller"> <textarea ng-change="evaluatechange()" id="ng-change-example1"></textarea> </div>
ng-model
it'll store value of input, textarea, or select.
your html should this:
<div ng-controller="examplecontroller"> <textarea ng-model="myvalue" ng-change="evaluatechange()" id="ng-change-example1"></textarea> </div>
then in controller can reference $scope.myvalue
hope helps! :)
Comments
Post a Comment