Answer the question
In order to leave comments, you need to log in
How to test controller with sockets in Angularjs?
The controller receives data via sockets.
Depending on the actions already taken by the user and the data received from the socket, one or another component should be shown in the interface.
In this example, I need to keep track of all the states of $scope.someBlock
angular
.module('myApp')
.controller('myApp', myApp);
function myApp($scope, socketIo){
var responseStatus = false;
$scope.buttonOne = true;
$scope.buttonTwo = false;
$scope.someBlock = false;
socketIo.on('someEvent', function(response){
//..какой-то код
responseStatus = response.status
newFunction()
})
newFunction(){
//..какой-то код
$scope.someBlock = responseStatus && $scope.buttonOne || $scope.buttonTwo && $scope.buttonOne
}
}
Answer the question
In order to leave comments, you need to log in
Возможно поможет использование www.bradoncode.com/blog/2015/05/27/ngmock-fundamen...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question