Bootstrap popover中的Angular元素

时间:2017-08-22 14:44:38

标签: javascript jquery twitter-bootstrap angular typescript

我正在使用带有角度2的Bootstrap,我的角度(点击)在我的popover内容中无效。

HTML:

 <p id="myPopover-profile">Operator</p>

    <div class="profile-option" id="profile-option">
      <div class="user-name"> Jhone Doe</div>
      <div class="line"> </div>
      <div class="end-session" (click)="endSession()"> End Session </div>
      <div class="logout"> Logout </div>
    </div>

</div>

TS:

  ngOnInit() {
    $('#myPopover-profile').popover({
      placement: 'bottom',
      toggle: 'popover',
      html: true,
      content:  function() {
        return $('#profile-option').html();
      }
    });

  }

  endSession(){
    console.log("test");
  }

1 个答案:

答案 0 :(得分:0)

为什么不为你的popover创建一个组件,你在popover html中执行类似<my-component></my-component>的操作,因此你可以使用 myComponent.ts 文件来获得你想要的逻辑。