javascript – 如何使用ng-change获取字段的值
栏目: JavaScript · 发布时间: 7年前
内容简介:翻译自:https://stackoverflow.com/questions/30947808/how-to-get-the-value-of-a-field-with-ng-change
我知道如何使用AngularJS中的ng-change对textarea中的用户输入作出反应.但是如何在Angular控制器中获取当前输入?我错过了$(this).value();在jQuery中.
<script>
angular.module('changeExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.evaluateChange = function() {
console.log("How do I get the current content of the field?");
};
}]);
</script>
<div ng-controller="ExampleController">
<textarea ng-change="evaluateChange()" id="ng-change-example1"></textarea>
</div>
NG-模型
它将存储输入,textarea或select的值.
你的HTML应该是这样的:
<div ng-controller="ExampleController"> <textarea ng-model="myValue" ng-change="evaluateChange()" id="ng-change-example1"></textarea> </div>
然后在您的控制器中,您可以使用$scope.myValue引用它
希望有所帮助!
翻译自:https://stackoverflow.com/questions/30947808/how-to-get-the-value-of-a-field-with-ng-change
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Python的pymysql查询结果获取字段列表
- Oracle/SQL Server/MySQL获取表及字段数据字典
- springboot~DTO字符字段与日期字段的转换问题
- Protocol Buffers 学习(2):字段类型和其他语言字段类型之间的映射
- Protocol Buffers 学习(2):字段类型和其他语言字段类型之间的映射
- PHPRAP 2.0.2 发布,接口和字段数据分离,字段使用单独数据表
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Google's PageRank and Beyond
Amy N. Langville、Carl D. Meyer / Princeton University Press / 2006-7-23 / USD 57.50
Why doesn't your home page appear on the first page of search results, even when you query your own name? How do other web pages always appear at the top? What creates these powerful rankings? And how......一起来看看 《Google's PageRank and Beyond》 这本书的介绍吧!