Note that there are some explanatory texts on larger screens.

plurals
  1. POThe view is not updated in AngularJS
    primarykey
    data
    text
    <p>Updating the model property has no effect on the view when updating the model in event callback, any ideas to fix this?</p> <p>This is my service:</p> <pre><code>angular.service('Channel', function() { var channel = null; return { init: function(channelId, clientId) { var that = this; channel = new goog.appengine.Channel(channelId); var socket = channel.open(); socket.onmessage = function(msg) { var args = eval(msg.data); that.publish(args[0], args[1]); }; } }; }); </code></pre> <p><code>publish()</code> function was added dynamically in the controller. </p> <p>Controller:</p> <pre><code>App.Controllers.ParticipantsController = function($xhr, $channel) { var self = this; self.participants = []; // here publish function is added to service mediator.installTo($channel); // subscribe was also added with publish $channel.subscribe('+p', function(name) { self.add(name); }); self.add = function(name) { self.participants.push({ name: name }); } }; App.Controllers.ParticipantsController.$inject = ['$xhr', 'Channel']; </code></pre> <p>View: </p> <pre><code>&lt;div ng:controller="App.Controllers.ParticipantsController"&gt; &lt;ul&gt; &lt;li ng:repeat="participant in participants"&gt;&lt;label ng:bind="participant.name"&gt;&lt;/label&gt;&lt;/li&gt; &lt;/ul&gt; &lt;button ng:click="add('test')"&gt;add&lt;/button&gt; &lt;/div&gt; </code></pre> <p>So the problem is that clicking the button updates the view properly, but when I get the message from the Channel nothings happens, even the <code>add()</code> function is called</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload