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 id="wrapper" ng-app="MyApp">
  <div ng-controller="AppCtrl">
    
    <!-- Just a jQuery Plugin -->
    <h3>Check out this plain old jQuery UI slider:</h3>
    <div id="slider"></div>
    <p>The slider's value is: <span id="slider-value">0</span></p>
    
    <!-- Trying to use a jQuery Plugin in an Angular Controller -->
    <h3>Check out this broken Angular slider:</h3>
    <div id="ng-slider"></div>
    <p>The slider's value is: {{brokenSliderValue}}</p>
    
    <!-- A functioning jQuery Plugin in an Angular Directive -->
    <h3>Check out this one-way data bound Angular slider:</h3>
    <div ng-slider-one model="mehSliderValue"></div>
    <p>The slider's value is: <input ng-model="mehSliderValue"/> (changing me won't update the slider)</p>
    
    <!-- A two-way data bound jQuery Plugin in an Angular Directive -->
    <h3>Check out this two-way data bound Angular slider:</h3>
    <div ng-slider-two model="betterSliderValue"></div>
    <p>The slider's value is: <input ng-model="betterSliderValue"/> (changing me WILL update the slider)</p>
    
    <!-- A jQuery Plugin in an Angular Directive in an ng-repeat -->
    <h3>Check out this <code>ng-repeat</code>-able Angular slider:</h3>
    <div ng-repeat="sliderValue in repeatSliderValues">
      <div ng-slider-two model="sliderValue"></div>
      <p>The slider's value is: <input ng-model="sliderValue"/></p>
    </div>
    
  </div>
</div>
            
          
!
            
              // Plain-ol' jQuery Plugin
$(document).ready(function() {
  $('#slider').slider({
    slide: function(event, ui) {
      $('#slider-value').text(ui.value);
    }
  });
});

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

app.controller('AppCtrl', ['$scope', function($scope) {
  
  $scope.brokenSliderValue = 0;
  $scope.mehSliderValue = 50;
  $scope.betterSliderValue = 50;
  
  $scope.repeatValueOne = 25;
  $scope.repeatValueTwo = 50;
  $scope.repeatValueThree = 75;
  $scope.repeatSliderValues = [
    $scope.repeatValueOne,
    $scope.repeatValueTwo,
    $scope.repeatValueThree
  ];
  
  // Broken slider
  $('#ng-slider').slider({
    slide: function(event, ui) {
      //$scope.$apply(function() {
        $scope.brokenSliderValue = ui.value;
      //});
    }
  });
  
}]);

// One-way bound slider
app.directive('ngSliderOne', [function() {
  return {
    restrict: 'A',
    scope: {
      'model': '='
    },
    link: function(scope, elem, attrs) {
      var $slider = $(elem);
      $slider.slider({
        value: +scope.model,
        slide: function(event, ui) {
          scope.$apply(function() {
            scope.model = ui.value;
          });
        }
      });
    }
  };
}]);

// Two-way bound slider
app.directive('ngSliderTwo', [function() {
  return {
    restrict: 'A',
    scope: {
      'model': '='
    },
    link: function(scope, elem, attrs) {
      var $slider = $(elem);
      $slider.slider({
        value: +scope.model,
        slide: function (event, ui) {
          scope.$apply(function() {
            scope.model = ui.value;
          });
        }
      });
      scope.$watch('model', function(newVal) {
        $slider.slider('value', newVal);
      });
    }
  }
}]);

            
          
!
999px
Loading ..................

Console