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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <html ng-app="myApp">
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
  </head>
  <body>
    
    <h2>Form Select Emulation with Bootstrap 3 Button Groups &amp; AngularJS</h2><br />
    
    <form ng-controller="btnSelectDemo">
      <div class="form-group">
        <label class="control-label col-md-9" for="btnSelect">{{label}}: </label>
        <div class="btn-toolbar">
          <div class="btn-group col-md-9">
            <button type="button" class="btn btn-default btn-lg col-md-6" data-toggle="dropdown" id="btnSelect">{{choosen.title}}</button>
            <button type="button" class="btn btn-info btn-lg dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
            
            <!-- Select dropdown -->
            <ul class="dropdown-menu col-md-12" role="menu">
              <li ng-repeat="book in items" ng-click="select($index)" ng-class="{true: 'selected'}[book.title == choosen.title]">
                <div class="row">
                <div class="col-md-12">
                  <span class="text-success" ng-show="book.title == choosen.title"><small><span class="glyphicon glyphicon-chevron-right"></span> Currently Selected<br /></small></span>
                    <strong class="text-info">{{book.title}}</strong>
                    <p class="text-muted">
                      Author(s): {{book.author}}<br />
                      Publish Date: {{book.released}}
                    </p>
                </div>
                </div>
              </li>
            </ul>
            
          </div> <!-- /.btn-toolbar -->
        </div> <!-- /.form-group -->
        
        <section class="row">
          <div class="col-md-12">
            <h3>Choosen Book</h3>
            <strong>{{choosen.title}}</strong>
            <p class="text-muted">
              Author(s): {{choosen.author}}<br />
              Published: {{choosen.released}}
            </p>
            <a ng-href="{{choosen.link}}" class="btn btn-info" target="_blank">Purchase @ Packt <span class="glyphicon glyphicon-play"></span></a>
          </div>
        </section>
    </form>
    
  </body>
</html> <!-- /ng-app -->
              
            
!

CSS

              
                body {
  padding: 20px;
}

.control-label {
  font-size: 18px;
}

button#btnSelect {
  text-align: left;
}

.dropdown-menu {
  margin-left: 15px;
}

.dropdown-menu li {
  cursor: pointer;
  padding: 5px;
}

.dropdown-menu li.selected {
  background-color: #ddefdd;
}

.dropdown-menu li:hover {
  background-color: #e9e9e9;
}

section {
  margin: 25px 0 0 15px !important;
}
              
            
!

JS

              
                angular.module('myApp',[])
.controller('btnSelectDemo',['$scope',function($scope){
  $scope.label = 'Select A Book';
  $scope.items = [
    {
      title: 'Mastering Web Application Development with AngularJS', 
      author: 'Peter Bacon Darwin, Pawel Kozlowski',
      released: 'August 2013',
      link: 'http://www.packtpub.com/angularjs-web-application-development/book'
    },{
      title: 'AngularJS Directives',
      author: 'Alex Vanston',
      released: 'September 2013',
      link: 'http://www.packtpub.com/angularjs-directives/book'
    },{
      title: 'Instant AngularJS Starter',
      author: 'Dan Menard',
      released: 'February 2013',
      link: 'http://www.packtpub.com/angularjs-to-build-dynamic-web-applications/book'
    }
  ];
  $scope.choosen = $scope.items[0];
  
  $scope.select = function(i){
    if(angular.isDefined(i))
      $scope.choosen = $scope.items[i];
  }; // end select
  
}]); // end btnSelectDemo / module(myApp)
              
            
!
999px

Console