下拉式切换以打开正文/页面加载

时间:2015-11-08 10:00:48

标签: angularjs angular-ui-bootstrap

我在页面中有下拉切换。我正在使用AngularJS。我想在页面加载时自动打开它。这是我的代码:

<div class="item dropdown customdrop" > 
  <a href="#" class="dropdown-toggle" >
    <img src="img/bell.png"> <span class="toggle-username">Alerts <i class="fa fa-caret-down"></i></span>   
  </a>    
  <ul class="dropdown-menu dropdown-menu-left" >
    <li class="dropdown-header">Notifications</li>
    <li class="divider"></li>
    <li>
      <div> <span class="text-left ndata">  Notifications </span>  <span class="text-right"> 5</span></div><br>
      <div> <span class="text-left ndata">  Notifications </span>  <span class="text-right"> 5</span></div><br>
      <div> <span class="text-left ndata">  Notifications </span>  <span class="text-right"> 5</span></div><br>
      <div> <span class="text-left ndata">  Notifications </span>  <span class="text-right"> 5</span></div><br>
      <div> <span class="text-left ndata">  Notifications </span>  <span class="text-right"> 5</span></div><br>
    </li>
  </ul>   
</div>

1 个答案:

答案 0 :(得分:0)

您需要在下拉列表中添加is-open选项:

<div class="item dropdown customdrop" is-open="status.isopen"> 

您的控制器应将其设置为默认打开:

.controller('MyCtrl', function ($scope) {
      $scope.status = {
            isopen: true
      };
});