Sam Daniel Sam Daniel - 6 months ago 15
jQuery Question

How to get the selected value of a drop down from front end in angular js

This is my controller

var controller = app.controller('ctrl', function ($scope) {
$scope.dropdown = ["Yearly", "Monthly", "Date"];
});


This is my HTML content:

<body ng-app="app" ng-controller="ctrl">
<div>
<table>
<tr>
<td>
<label>Select :</label>
</td>
<td>
<select data-ng-model="option">
<option ng-repeat="date in dropdown" ng-bind="date" value="{{date.value}}"></option>
</select>
</td>
</tr>

<tr ng-show="option == 'Yearly'">
<td>
<label>From:</label>
</td>
<td>
<input type="date" ng-model="fromdate" id="fromdate" date-picker />
</td>
<td>
<label>To:</label>
</td>
<td>
<input type="date" ng-model="todate" date-picker />
</td>
</tr>
</table>
</div>




I am trying to get the value user selects from the dropdown in the front end, I need to hide or show some textboxes based on the value selected in the dropdown.

Answer

ng-model and not ng-bind however i suggest using ng-options...

 <select ng-options="date for date in dropdown" ng-model="option"></select>

Docs here