调整angularJS中文本区域的大小(在uib选项卡内)
嗨,我在AngularJS中使用它来根据输入调整文本区域的大小。我使用的模板如下(description.tpl.html):调整angularJS中文本区域的大小(在uib选项卡内),angularjs,angularjs-directive,textarea,Angularjs,Angularjs Directive,Textarea,嗨,我在AngularJS中使用它来根据输入调整文本区域的大小。我使用的模板如下(description.tpl.html): 提前谢谢 我添加了一个布尔范围变量,并在选择选项卡时将其设置为true。在指令中添加了以下代码: scope.$watch('descriptionTabSelected', function(descriptionTabSelected){ if(descriptionTabSelected){
提前谢谢 我添加了一个布尔范围变量,并在选择选项卡时将其设置为true。在指令中添加了以下代码:
scope.$watch('descriptionTabSelected', function(descriptionTabSelected){
if(descriptionTabSelected){
element.css({ 'height': 'auto', 'overflow-y': 'hidden' });
$timeout(function () {
element.css('height', element[0].scrollHeight + 'px');
}, 100);
}
});
<uib-tab heading= DESCRIPTION >
<div ng-include="'description.tpl.html'"></div>
</uib-tab>
element.css({ 'height': 'auto', 'overflow-y': 'hidden' });
element.css('height', element[0].scrollHeight + 'px');
scope.$watch('descriptionTabSelected', function(descriptionTabSelected){
if(descriptionTabSelected){
element.css({ 'height': 'auto', 'overflow-y': 'hidden' });
$timeout(function () {
element.css('height', element[0].scrollHeight + 'px');
}, 100);
}
});