Hi All,
I am developing a real time application using websocket. Now I want the ionic application reacts (change it’s model and view) when receiving message from the server. I would like to have your advice on it.
Here are some codes to clarify:
var ws;
angular.module(‘starter.controllers’, [])
.controller(‘GameCtrl’, function($scope, $state, $stateParams, $timeout, $ionicLoading) {
$scope.aList = [{“1”: “2”, “3”: “4”}]; // the entries shown in the list (view)
})
.controller(‘StartupCtrl’, function($scope, $q, $state, $ionicPopup, LoginService) {
$scope.startup = function() {
LoginService.signin(user.username, user.password);
ws = new WebSocket(......);
ws.onmessage = function (event) {
//I want to change the $scope.aList model in GameCtrl controler and let the view change also.
$scope.aList = [{"5": "6", "6": "7"}];
};
}
$scope.startup();
});
Thank you for your help.
best regards,
b