简体   繁体   English

在Angular JS中动态添加textarea控件

[英]Add textarea control dynamically in Angular JS

Please help me on below requirement with code in angular js, 请在以下要求下用angular js中的代码帮助我,

My page should have an ADD button, when we click on ADD I should add a textarea control. 我的页面上应该有一个添加按钮,当我们点击添加时,我应该添加一个textarea控件。 I should be able to add infinite number of textarea controls by clicking this ADD button. 通过单击此ADD按钮,我应该能够添加无限数量的textarea控件。

you can do like this.this is the simplest method: see plunker 您可以这样做。这是最简单的方法: 请参阅 plunker

html: 的HTML:

    <div ng-repeat="textArea in textAreas">
       <textarea id="maxlength_textarea" class="form-control" maxlength="225" rows="2" ng-  model="textArea.textBox" placeholder="textbox"></textarea>

    </div>

<button class="btn btn-info" ng-click="addMore()">Add More</button>

in controller: 在控制器中:

$scope.textAreas=[];
    $scope.addMore=function(){
    $scope.textAreas.push({textBox:""});
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM