angular.module('MyApp')
    .directive('autoTextare', ['$timeout', function ($timeout) {
        return {
            restrict: 'A',
            require: '^?ngModel',
            link: function ($scope, iElm, iAttrs, controller) {
                var nowEle = angular.element(iElm[0]);
                $timeout(function () {
                    nowEle.css('height', 'auto');
                    nowEle.css('height', iElm[0].scrollHeight + 'px');
                }, 100)
                iElm.on('input', function (event) {
                    nowEle.css('height', 'auto');
                    nowEle.css('height', this.scrollHeight + 'px');
                })
            }
        }
    }])
    

 

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-12-22
相关资源
相似解决方案