Skip to content

Instantly share code, notes, and snippets.

Created March 25, 2013 20:15
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johncblandii/5240310 to your computer and use it in GitHub Desktop.
A simple input[type=range] directive for AngularJS. There is an issue databinding to value changes:
var myApp = angular.module("myApp", []);
myApp.directive("rangeChange", function ($rootScope) {
var linker = function (scope, element, attrs) {
var updateScope = function () {
//may need to scope.$apply here
element.bind("change", updateScope);
updateScope(); //get the default value
return {
link: linker
* <input type="range" range-change="myScopeMethodOnAController" />
Copy link

teisnet commented Jan 23, 2014

scope[attrs.rangeControl]... should be scope[attrs.rangeChange]...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment