The variable is changing before Angular has completed the $digest
cycle and rendered the view. Try calling emit
asynchronously via $timeout
, which will allow the framework to render the current view and then update it later when your data is finished loading:
$scope.verify = function () {
function afterLoading(){
socket.emit('verify', $scope.data, function(result) {
$scope.status = result;
});
}
$scope.status = 'verifying';
$timeout(afterLoading, 0);
};
(Also remember to inject the $timeout
service in your controller)