Hi,
I'm rather new to AngularJS and JavaScript, and I'm in the process of learning them. So I was tinkering around a little bit trying to understand different concepts and this is one that's driving me crazy. I'm calling the addcomment() function from a html file. The function gets called, but everytime i want this code to display:
<p ng-repeat="x in messages">{{x}}<br></p>
It displays to me only one "Hi"
I want a new "hi" to be pushed into my array everytime I call the function from the HTML file. That is, if the function addcomment() has been called 5 times, then I want 5 "hi" in my array called messages[]. It seems to me that everytime I call the function, the array gets reinitialised to empty array. How do I go around this?
This is the code:
.controller('Ctrl',function($scope){
$scope.messages=[""];