从输入中获取值 (AngularJS) [英] Get value from input (AngularJS)
本文介绍了从输入中获取值 (AngularJS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下输入并且需要它们的值:
I have the following inputs and need their values:
<input type="hidden" ng-model="movie" value="harry_potter"/>
<input type="text" ng-model="year" value="2000"/>
如何获取每个输入的值?
What can I do to get the value of each input?
推荐答案
如果你想在前端获取 Javascript 中的值,你可以使用原生方式来完成:
If you want to get values in Javascript on frontend, you can use the native way to do it by using :
document.getElementsByName("movie")[0].value;
其中 "movie"
是您的 input
如果你想在 angular.js 控制器上得到它,你可以使用;
If you want to get it on angular.js controller, you can use;
$scope.movie
这篇关于从输入中获取值 (AngularJS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文