mercredi 6 septembre 2017

Real time table AngularJS

I'm working with the Twitter stream API. My server gets tweets from a concretes hashtags. For this I use a IO socket. The client receives the messages from the socket:

socket.on('tweet', function(msg){
        console.log(msg);
        $scope.streaming.push(msg);
    });

You can see that also I push the messages in a table called streaming. In the HTML I have the ng-repeat directive:

<table class="table table-bordered table-hover table-striped">
                        <tr ng-repeat="tweet in streaming">
                            <td>
                                <div class="col-lg-2">
                                    <i class="fa fa-twitter" aria-hidden="true"></i>
                                </div>
                                <div class="col-lg-10">
                                    
                                </div>
                            </td>
                        </tr>
                    </table>

The table starts empty and fills as the tweets come in. But in the page there aren't changes. The tweets only appear when I stop the server.

Why does it happen this?




Aucun commentaire:

Enregistrer un commentaire