This topic contains 4 replies, has 2 voices, and was last updated by Jai Jai 7 months, 2 weeks ago.

popover no working in ngFor variable which gets set via a API call


  • neelsaraiya
    Participant

    Posts: 4
    Member Reply #19207

    Please see attachment of my code to generate button popover in a ngFOR

    The allQuestionList gets set via a API Call

    If I just return _allQuestionList = [1,2,3,4] on ine 1 of the function;

    It will create 4 buttons with working popover. But if I do a http api call the popovers dont work. Please help

    • This topic was modified 7 months, 3 weeks ago by  neelsaraiya.
    Attachments:
    You must be logged in to view attached files.
    Jai
    Jai
    Keymaster

    Posts: 2715
    Support Staff Reply #19227

    Hi 🙂

    Can you try to init the popover after view init?

    ngAfterViewInit() {
    mApp.initPopovers();
    }

    Thanks


    neelsaraiya
    Participant

    Posts: 4
    Member Reply #19232

    Hi Jai,

    Thanks for your reply. Do I have to import any library into my component to use the function initPopovers() ?

    Not a angular expert here. appreciate your help.

    Neel


    neelsaraiya
    Participant

    Posts: 4
    Member Reply #19234

    Hi Jai,

    I have modified the script.bundle.js to add some console errors.

    the log always prints “here” but never prints $(this)

    The only way I can get it work is if I add a delay in the ngAfterViewInit

    ngAfterViewInit() {
    $timeout(function() {}, 2000);
    mApp.initPopovers();
    }

    var initPopovers = function() {
    console.log(‘here’);
    // init bootstrap popover
    $(‘[data-toggle=”m-popover”]’).each(function() {
    console.log($(this));
    initPopover($(this));
    });
    }

    Not a robust solution in my opinion. Hoping you can help me out with a better solution.

    Jai
    Jai
    Keymaster

    Posts: 2715
    Support Staff Reply #19257

    Hi 🙂

    Can you move mApp.initPopovers(); inside subscribe, after getting this._allQuestionList

    Thanks

You must be logged in to reply to this topic.