I am currently working on a project that involves multiple controllers. One of these controllers requires me to establish a web socket connection, while another needs to listen for messages and update the $scope if necessary. Can you please help me by providing an example similar to the one below:
app.controller('MainCtrl', ['$scope', function($scope) {
$scope.testProp = {};
$scope.testProp2 = '';
// code to listen for messages here and update $scope.testProp && $scope.testProp2
}]);
app.controller('SearchCtrl', ['$scope', function($scope) {
// code to open web socket connection here
}]);
P.S. I realize that this issue may seem straightforward, but as someone new to AngularJS and WebSockets, I would greatly appreciate any assistance. Unfortunately, I don't have much time to dive into the documentation at the moment.