Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div ng-app="myApp"  class="container">
  <h3>
    Angularjs Dropdown/Select
    <a href="http://www.advancesharp.com/blog/1196/angularjs-dropdown-select-value-text-multiple-values-with-demo">
      Detailed blog
    </a>
  </h3>
  <form class="form-horizontal" ng-controller="dropdownCtrl">
       
    
    <div class="form-group">
      <label for="country" class="col-sm-2 control-label">Bind Comma Separated String</label>
      <div class="col-sm-7">             
        <select ng-model="csValue"               
                ng-options="x for x in csString.split(',') "
                class="form-control" 
                ng-required="true">
          <option value="">-- Choose Month --</option>
        </select> 
        <div>
         Selected Month:  {{csValue}}
        </div>
      </div>
    </div>    
    <div class="form-group">
      <label for="country" class="col-sm-2 control-label">Bind String Array </label>
      <div class="col-sm-7">             
        <select ng-model="month"               
                ng-options="x for x in months"
                class="form-control" 
                ng-required="true">
          <option value="">-- Choose Month --</option>
        </select> 
        <div>
         Selected Month:  {{month}}
        </div>
      </div>
    </div>
    
     <div class="form-group">
      <label for="country" class="col-sm-2 control-label">Bind only Id  </label>
      <div class="col-sm-7">             
        <select ng-model="countryId"               
                ng-options="x.id as x.name for x in countries | orderBy:'name'"
                class="form-control" 
                ng-required="true">
          <option value="">-- Choose Country --</option>
        </select> 
        <div>
         Selected Country Id :  {{countryId}}
        </div>
      </div>
    </div>    
    <div class="form-group">
      <label for="country" class="col-sm-2 control-label">Bind Id & Text  </label>
      <div class="col-sm-7">             
        <select ng-model="countryIdText"               
                ng-options="x as x.name for x in countries track by x.id"
                class="form-control" 
                ng-required="true">
          <option value="">-- Choose Country --</option>
        </select> 
        <div>
         Selected Country Id & Text:    {{countryIdText.id}} -{{countryIdText.name}}
        </div>
      </div>
    </div>
    
    <div class="form-group">
      <label for="country" class="col-sm-2 control-label">Bind Id, Name & Role   </label>
      <div class="col-sm-7">             
        <select ng-model="user"               
                ng-options="x as (x.id + ': ' + x.name + ' [' + x.role + ']') for x in users track by x.id"
                class="form-control" 
                ng-required="true">
          <option value="">-- Choose User --</option>
        </select> 
        <div>
         Selected Id, Name & Role:    {{user.id}} -{{user.name}} - {{user.role}}
        </div>
      </div>
    </div>
  </form>
</div>
              
            
!

CSS

              
                select.ng-invalid{
    border-left: 5px solid #ff0000;
    background-color: #FFEBD6;
}
select.ng-valid{
    background-color: #FFFFFF;
    border-left: 5px solid #088b0b;
}


              
            
!

JS

              
                var app = angular.module('myApp', []);

app.controller('dropdownCtrl', function ($scope) {
    
  
 $scope.csValue = '7';    
 $scope.csString = "1,2,3,4,5,6,7,8,9,10";
  
  $scope.month = 'March';
  $scope.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
 
  
 
 $scope.countryId = 3;
 $scope.countryIdText= {id: 2, name: 'Canadan'};
 $scope.countries = [
        {id: 1, name: 'USA'},
        {id: 2, name: 'Canada'},
        {id: 3, name: 'Maxico'},
        {id: 4, name: 'Siriya'},
        {id: 5, name: 'Bulgaria'}
     ];
  
  
$scope.user = {id: 2, name: 'Arron', role: 'Analyst'};
$scope.users = [
    {id: 1, name: 'Ahmad', role: 'Admin'},
    {id: 2, name: 'Arron', role: 'Analyst'},
    {id: 3, name: 'Robert', role: 'Guest'},
    {id: 4, name: 'Baldwin', role: 'Admin'},
    {id: 5, name: 'Azure', role: 'Viewer'}
  ];

  });

              
            
!
999px

Console