Skip to content

Instantly share code, notes, and snippets.

@schmidt1024
Forked from thomseddon/gist:4703968
Last active October 16, 2015 08:11
Show Gist options
  • Save schmidt1024/3a4c1b532e4e041a5c2f to your computer and use it in GitHub Desktop.
Save schmidt1024/3a4c1b532e4e041a5c2f to your computer and use it in GitHub Desktop.
simple autogrow directive for textareas in angularjs
// Usage: <textarea auto-grow></textarea>
appModule.directive('autoGrow', function() {
return function(scope, element, attr){
var update = function(){
element.css("height", "auto");
element.css("height", element[0].scrollHeight + "px");
};
scope.$watch(attr.ngModel, function(){
update();
});
attr.$set("ngTrim", "false");
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment