cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <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>
            
          
!
            
              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
Loading ..................

Console