Skip to content

Instantly share code, notes, and snippets.

@return-none
Created April 2, 2015 10:13
Show Gist options
  • Save return-none/39dd86fdcb39fef67b18 to your computer and use it in GitHub Desktop.
Save return-none/39dd86fdcb39fef67b18 to your computer and use it in GitHub Desktop.
angular.module('myApp')
.directive('elastic', [
'$timeout',
function ($timeout) {
'use strict';
return {
restrict: 'A',
link: function ($scope, element) {
var resize = function () {
element[0].style.height = 'auto';
element[0].style.height = '' + element[0].scrollHeight + 'px';
};
element.on('blur keyup change', resize);
$timeout(resize, 0);
}
};
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment