Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created June 12, 2014 08:59
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 cpoDesign/e9267a424a623ba34e91 to your computer and use it in GitHub Desktop.
Save cpoDesign/e9267a424a623ba34e91 to your computer and use it in GitHub Desktop.
Implementing select dropdown with default select option
app.controller('myController', function($scope){
$scope.teams = [
{id:1, name:'team 1'},
{id:2, name:'team 2'},
{id:3, name:'team 3'}];
// if I want to preselect item I can do following
// $scope.myTeam = 1;
});
<select ng-options="team.id as team.text for team in teams" name="teamOption" ng-model="myTeam" class="InputBox">
<option style="display:none" value="">Select a team</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment