Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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="contactApp" class="container" style="margin-top: 10px;" ng-controller="ContactController as vm">
     <div class="row">
          <div class="col-sm-4 form-group">
               <label class="control-label">First Name</label>
               <input type="text" class="form-control" ng-model="vm.contact.firstName" />
          </div>
          <div class="col-sm-4 form-group">
               <label class="control-label">Last Name Name</label>
               <input type="text" class="form-control" ng-model="vm.contact.lastName" />
          </div>
          <div class="col-sm-4 form-group">
               <label class="control-label">State</label>
               <select class="form-control" ng-model="vm.contact.stateCode" ng-options="state.stateCode as state.stateName for state in vm.states">
                    <option value="">--Select One--</option>
               </select>
          </div>
          <div class="col-sm-4 form-group">
               <label class="control-label">County</label>
               <select class="form-control" ng-model="vm.contact.county" ng-options="county.countyName for county in vm.counties">
                    <option value="">--Select One--</option>
               </select>
          </div>
     </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                angular.module('contactApp', []);

var Contact = function (data) {
	var _this = this;
	_this.firstName = data.firstName;
	_this.lastName = data.lastName;
	_this.stateCode = data.stateCode;
     _this.county = data.county;
};

ContactController.$inject = ['$scope'];
function ContactController ($scope) {
     var _this = this;
     
     _this.contact = new Contact({ firstName: 'Ken', lastName: 'Howard', stateCode: 'OR', county: 'Multnomah' });
     
     _this.states = [
          { stateCode: 'CA', stateName: 'California' },
          { stateCode: 'ID', stateName: 'Idaho' },
          { stateCode: 'OR', stateName: 'Oregon' },
          { stateCode: 'WA', stateName: 'Washington' }
     ];
     
     _this.counties = []; // We'll be updating this based on the state selected.
     
     $scope.$watch(function () {
          // The property we are watching.
          return _this.contact.stateCode;
     }, function (newValue, oldValue) {
          // When the property changes. (this occurs on initial load as well as when the model is updated in anyway, by the user or by another method.)
          if (newValue === 'OR') {
               _this.counties = [
                    { countyId: 1, countyName: 'Clackamas' },
                    { countyId: 2, countyName: 'Multnomah' },
                    { countyId: 3, countyName: 'Washington' }
               ];
           } else if (newValue === 'WA') {
               _this.counties = [
                    { countyId: 4, countyName: 'unknown' },
                    { countyId: 5, countyName: 'somewhere' },
                    { countyId: 6, countyName: 'nothere' }
               ];
           } else if (newValue === 'CA') {
               _this.counties = [
                    { countyId: 7, countyName: 'Orange' },
                    { countyId: 8, countyName: 'Los Angeles' },
                    { countyId: 9, countyName: 'San Diego' }
               ];
           } else if (newValue === 'ID') {
               _this.counties = [
                    { countyId: 10, countyName: '?' },
                    { countyId: 11, countyName: 'potato land' },
                    { countyId: 12, countyName: 'snake river' }
               ];
           }
     });
}

angular.module('contactApp').controller('ContactController', ContactController);


              
            
!
999px

Console