How to append directives based on conditions

后端 未结 1 799
说谎
说谎 2021-01-27 15:34

I have 2 different directives. The first one is returns an iframe with a live video, and the second returns an iframe with a recent video.

The condition is: if live cont

1条回答
  •  天涯浪人
    2021-01-27 16:25

    Instead of handling the logic in the controller you can control it in UI as it will be easier.

    -----Other Html Codes-----
    
    
    -----Other Html Codes-----
    

    And you can remove following lines of code from the controller

    var liveIframe = '';
    var videoIframe = '';
    
    if (vm.live.items[0] != undefined) {
        $('.iframe-container').append(liveIframe);
    } else {
        $('.iframe-container').append(videoIframe);
    }
    

    0 讨论(0)
提交回复
热议问题