Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have this code and on socket.connect I want to be able to hide the alert that was shown in socket.disconnect.

I see there is a reference in the docs to $scope methods hide, show, and toggle but how can I use them in this example?

socket.on('disconnect', function () {

  // Show login error message
  $alert({
    title: 'Connection lost.',
    content: 'Please reload the page.',
    placement: 'top-right',
    type: 'danger',
    show: true
  });
});

socket.on('connect', function () {
  // TODO: Check if connection alert is showing and if it is, hide it
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
143 views
Welcome To Ask or Share your Answers For Others

1 Answer

I feel stupid today...

var alert = $alert({
    title: 'Connection lost.',
    content: 'Please reload the page.',
    placement: 'top-right',
    type: 'danger',
    show: false
});

socket.on('disconnect', function () {
    alert.show();
});

socket.on('connect', function () {
    alert.hide();
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...