Let's take a look at this snippet of code:
export class TestController {
constructor() {
this.socket = io();
this.movies = {};
this.socket.emit('getAllMovies', '');
this.socket.on('allMovies', this.listMovies.bind(this));
}
listMovies(data){
this.movies = JSON.parse(data);
console.log(this.movies);
}
}
Now, let's consider the view (using controllerAs syntax):
<div>
{{ctrl.movies}}
</div>
Upon opening the page, the initial display is {}, then when data from the websocket arrives correctly, it binds to this.movies but nothing changes. It seems like the two-way binding is not working properly. Can anyone provide insight into why this might be happening?