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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -