我正在使用ng2引导程序和更新的angular cli 1.0版本,在那之后得到上述错误这里是我的代码。你能帮我解决这个问题吗
γ

<ul class="nav navbar-nav ml-auto">
    <li class="nav-item dropdown" dropdown (onToggle)="toggled($event)">
        <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"
            dropdownToggle>
            <i class="icon-bell"></i> <span class="badge badge-pill badge-danger">5</span>
        </a>
        <div class="dropdown-menu dropdown-menu-right" dropdownMenu aria-labelledby="simple-dropdown">
            <a class="dropdown-item" href="#"><i class="fa fa-envelope"></i> You have 4 videos to Validate</a>
            <a class="dropdown-item" href="#"><i class="fa fa-trophy"></i> Need to Declare winners for week 34</a>
        </div>
    </li>
    <li class="nav-item dropdown" dropdown (onToggle)="toggled($event)">
        <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"
            dropdownToggle>
            <img src="assets/img/avatars/6.jpg" class="img-avatar" alt="[email protected]">
            <span class="hidden-md-down">Super Admin</span>
        </a>
        <div class="dropdown-menu dropdown-menu-right" dropdownMenu aria-labelledby="simple-dropdown">
            <a class="dropdown-item" href="#"><i class="fa fa-key"></i> Change Password</a>
            <a class="dropdown-item" href="#"><i class="fa fa-lock"></i> Logout</a>
        </div>
    </li>
</ul>

最佳答案

根据docs它看起来像是您在*上丢失了dropdownMenu。应该是

<div class="dropdown-menu dropdown-menu-right" *dropdownMenu aria-labelledby="simple-dropdown">

因此*dropdownMenu需要*,但dropdown指令不需要。
文档示例:
<div class="btn-group" dropdown>
  <button dropdownToggle type="button" class="btn btn-primary dropdown-toggle">
    Button dropdown <span class="caret"></span>
  </button>
  <ul *dropdownMenu class="dropdown-menu" role="menu">
    <li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
    <li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
    <li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
    <li class="divider dropdown-divider"></li>
    <li role="menuitem"><a class="dropdown-item" href="#">Separated link</a>
    </li>
  </ul>
</div>

关于angularjs - 没有TemplateRef的提供者! (ng2 bootstrap ),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43255137/

10-10 18:46