Skip to content

Instantly share code, notes, and snippets.

@tkc
Created October 7, 2015 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkc/80f0242a7bba350138d7 to your computer and use it in GitHub Desktop.
Save tkc/80f0242a7bba350138d7 to your computer and use it in GitHub Desktop.
<select
ng-model="selectedMonth"
ng-change="select()"
ng-options="month as month.label for month in months"></select>
<input type="hidden" name="test" value="@{{selectedMonth.num}}">
@{{selectedMonth.label | json}}
var months = [
{num: 1, label: "January"},
{num: 2, label: "February"},
{num: 3, label: "March"},
{num: 4, label: "April"},
{num: 5, label: "May"},
{num: 6, label: "June"},
{num: 7, label: "July"},
{num: 8, label: "August"},
{num: 9, label: "September"},
{num: 10, label: "October"},
{num: 11, label: "November"},
{num: 12, label: "December"}
];
var selectValue = 6;
$scope.months = months;
$scope.selectedMonth = months[0];
_.each(months, function (v, k) {
if (v.num == selectValue) {
$scope.selectedMonth = $scope.months[2];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment