If he can serve someone, I changed the benshope solution a bit, since I need to make textarea grow even when the user returns the carriage.
Therefore, instead of listening to changes on the input value (which did not always work when performing a carriage return), I send an input event to the text box.
(function () { 'use strict'; angular .module('app') .directive('expandingTextarea', expandingTextarea); function expandingTextarea() { return { restrict: 'A', controller: function ($scope, $element, $attrs, $timeout) { $element.css('min-height', '0'); $element.css('resize', 'none'); $element.css('overflow-y', 'hidden'); setHeight(0); $timeout(setHeightToScrollHeight); function setHeight(height) { $element.css('height', height + 'px'); $element.css('max-height', height + 'px'); } function setHeightToScrollHeight() { console.log('set height'); setHeight(0); var scrollHeight = angular.element($element)[0] .scrollHeight; if (scrollHeight !== undefined) { setHeight(scrollHeight); } } angular.element($element)[0].addEventListener("input", setHeightToScrollHeight); } }; }})();
source share