javascript - Push input to array and clear input not working as expected -


I have an administrator that brings data from the factory, as follows:

  .controller ('ChatDetailCtrl', function ($ scope, $ state page, message) {$ 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);}})  < / Pre> 

I use an NG-Encore to display messages on the template. I have an input that uses ng-click to run the sending problem The problem is, when you send it, then it is added to its array, however if you do this, it will send you a new message Updates the sent message instead of allowing it.

How do I input the array, the way I can be repeated it several times?

Try doing this so that you are not pushing the same reference forward, but similar to the input Get a completely new object

  .controller ('ChatDetailCtrl', function ($ diameter, $ state page, message) {$ scope.messages = Messages ($ StateParams.partnerId); $ Scope.send = function {input} {input.id = Math.random (); input.sent = true; input.time = new date (); $ scope.messages.data push (enigmatic input); Console.log ($ scope.messages);}})  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -