0

Ques: I want to add the copy of label tag in result div each time when i press the submit button using Angularjs. Any help would be appreciated.

<label class="item item-input">
<input type="text" placeholder="Name">
</label>

<div class="result">
</div>

<button type="submit" class="button button-positive">
Submit
</button>

1 Answer 1

2

I've no idea what do you want obtain by doing that, but please see example below that should helps you a bit.

var app = angular.module('app',[]);

app.controller('fCtrl', function($scope){
  
  $scope.names = [
    
    {id:1}
  ];
  
  $scope.add = function(){
  
    var tmp =  $scope.names[0];
  
    
     $scope.names.push(tmp) 
    
  }
  
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
  <div ng-controller="fCtrl">

    <label class="item item-input" ng-repeat="name in names track by $index">
      <input type="text" placeholder="Name">
    </label>

    <div class="result">
    </div>

    <button type="button" class="button button-positive" ng-click="add()">
      Submit
    </button>
  </div>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. Working fine as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.