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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -