0

I am trying to display image on the body using jQuery in my angular application. jQuery script is not working in my angular application for popup. I am not able to find out where is the issue.So, How to resolve this issue?

app.component.ts:

 ngOnInit() {
    var container = $('<div id="container"></div>');
    container.show();
    setTimeout(function () {
      container.appendTo(document.body);
    }, 10000);

    $('.popupbox').show();
    $('.close').click(function () {
      $('.popupbox').hide();
      container.appendTo(document.body).remove();
      return false;
    });
    $('.close').click(function () {
      $('.popupbox').hide();
      container.appendTo(document.body).remove();
      return false;
    });
  }

Demo: https://stackblitz.com/edit/angular-jquery-modal-uvr9f4?file=app%2Fapp.component.ts

4
  • 3
    It’s just not a good idea to mix jQuery with Angular.. Commented Sep 29, 2021 at 17:28
  • @MikeOne: You have any other idea? Commented Sep 29, 2021 at 17:30
  • This can be fairly easily rewritten using Angular mechanisms.. Commented Sep 29, 2021 at 17:32
  • @MikeOne: How can do it? Please edit my stackblitz Commented Sep 29, 2021 at 17:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.