I have a controller which fetches data from a factory, as follows:
.controller('ChatDetailCtrl', function($scope, $stateParams, Messages) {
$scope.messages = Messages.get($stateParams.partnerId);
$scope.send = function (input) {
input.id = Math.random();
input.sent = true;
input.time = new Date();
$scope.messages.data.push(input);
console.log($scope.messages);
}
})
I use an ng-repeat to display the messages on the template. I then have an input which uses ng-click to run send. The problem is, when you send it then its added to the array, however if you carry on typing then it updates the sent message, rather than allowing you to send a new one.
How can I pass the input to the array, in a way which allows me to repeat it many times?
input = {}after you pushed it?inputinto the Array, you still keep a reference inside your model ($scope), you dont refresh it.