subhra subhra - 1 year ago 68
AngularJS Question

can not add new element using ng-repeat in Angular.js

I need one help. I need to create extra input element using

in angular.js. I did something but its not working. I explaining my code below.

<li ng-repeat="r in arr">
<input type="text" ng-model="r.uname">
<button type="button" id="btn" ng-click="create();">Add</button>

Here I need when user will click on add button the new input field will create just below the first one. My scripting side code is given below.

<script type="text/javascript">
function ContactController($scope){

But here i am unable to generate the new input type element. Please help me.

Answer Source

I don't see an error in your code. it works:

$scope.arr=[{uname: null}];
  $scope.create = function(){
      uname: null
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download