Created
April 2, 2015 10:13
-
-
Save return-none/39dd86fdcb39fef67b18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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