自适应textArea
<textarea id="textarea" ng-model="img.name" placeholder="请输入文字备注" rows=1 cols=40 style='overflow:scroll;overflow-y:hidden;overflow-x:hidden'
onfocus="window.activeobj=this;this.clock=setInterval(function(){activeobj.style.height=activeobj.scrollHeight+'px';},200);" onblur="clearInterval(this.clock);"></textarea>
列表中的textArea 可通过定时器进行刷新
app.controller('MainCtrl', function($interval) {
$scope.autoTextArea = function(){
$interval(
function() {
var activeobj=document.getElementById(id);
activeobj.style.height=activeobj.scrollHeight+'px';
}
},
1000*1
);
}
在页面通过js将回车转化为
var reg=new RegExp("\n","g"); //new RegExp("\r\n","g")
content= content.replace(reg,"<br>");
在类中将数据在转化回来
content=content.replaceAll("<br>", "\n");
//content=content.replaceAll("<br>", "\r\n");