18 lines
512 B
JavaScript
18 lines
512 B
JavaScript
// original idea from blockloop: http://stackoverflow.com/a/24090733
|
|
app.directive('elastic', [
|
|
'$timeout',
|
|
function($timeout) {
|
|
return {
|
|
restrict: 'A',
|
|
link: function($scope, element) {
|
|
$scope.initialHeight = $scope.initialHeight || element[0].style.height;
|
|
var resize = function() {
|
|
element[0].style.height = $scope.initialHeight;
|
|
element[0].style.height = "" + element[0].scrollHeight + "px";
|
|
};
|
|
element.on("input change", resize);
|
|
$timeout(resize, 0);
|
|
}
|
|
};
|
|
}
|
|
]); |