cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console