I am trying to append the form submit using Angular but I receive an error when I submit more than one consecutive similar values. For example if I submit "John" and then try to submit another "John" the program crashes. Can someone explain it to me? and a tip how to fix it?
*Also can anyone tell me how to append the results in one line?
angular.module("displayText", [])
.controller("submitText", function($scope) {
$scope.outputArr = [];
$scope.print = function() {
$scope.outputArr.push($scope.inputText);
$scope.inputText = '';
};
});
<html ng-app="displayText">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<body ng-controller="submitText">
<div>
<form method="get">
<input type="text" name="post" ng-model="inputText" required/>
<button ng-click="print(inputText)">Submit</button>
</form>
<div id="page">
<p ng-repeat="text in outputArr">{{text}}</p>
</div>
</div>
</body>
</html>