首页 > 其他 > 详细

angular指令系列---多行文本框自动高度

时间:2016-06-23 20:40:37      阅读:840      评论:0      收藏:0      [点我收藏+]
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‘);
                })
            }
        }
    }])
    

 

angular指令系列---多行文本框自动高度

原文:http://www.cnblogs.com/HeJason/p/5612010.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!