Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value from input (AngularJS) [closed]

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?

like image 918
Bun Suwanparsert Avatar asked Jan 10 '14 09:01

Bun Suwanparsert


2 Answers

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;

Where "movie" is the name of your input <input type="text" name="movie">

If you want to get it on angular.js controller, you can use;

$scope.movie
like image 185
Hüseyin BABAL Avatar answered Oct 16 '22 11:10

Hüseyin BABAL


If your markup is bound to a controller, directive or anything else with a $scope:

console.log($scope.movie);

like image 37
user2422960 Avatar answered Oct 16 '22 13:10

user2422960