Skip to content

Instantly share code, notes, and snippets.

@vicatcu
Last active April 24, 2016 16:03
Show Gist options
  • Save vicatcu/a2b4534840d235c4f805a9f2b66c2e06 to your computer and use it in GitHub Desktop.
Save vicatcu/a2b4534840d235c4f805a9f2b66c2e06 to your computer and use it in GitHub Desktop.
<form name="myForm">
<label for="duration"> Duration: </label><br>
<select name="duration" ng-model="selectedDuration" ng-change="durationChange()">
<option ng-repeat="(key, value) in durations" value="{{value}}" selected="{{isSelectedDurationOption(value)}}">
{{key}}
</option>
</select>
</form>
$scope.durations = {
"15 minutes": 900,
"1 hour": 3600,
"8 hours": 28800,
"16 hours": 57600,
"24 hours": 86400
};
$scope.selectedDuration = 3600;
$scope.durationChange = function(){
console.log("selection changed to " + $scope.selectedDuration);
};
$scope.isSelectedDurationOption = function(value){
if(value == $scope.selectedDuration){
return 'selected';
}
return 'false';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment