我的NgbDropdown是这样的
<div ngbDropdown class="d-flex justify-content-end">
<button class="btn" id="dropdownMenu" ngbDropdownToggle>Toggle
dropdown</button>
<div ngbDropdownMenu aria-labelledby="dropdownMenu">
<button ngbDropdownItem>Action - 1</button>
<button ngbDropdownItem>Another Action</button>
<button ngbDropdownItem>Something else is here</button>
</div>
</div>
它可以工作,但当我有这样的子组件时
导航条.组件.html
<div ngbDropdown class="d-flex justify-content-end">
<button class="btn" id="dropdownMenu" ngbDropdownToggle>Toggle
dropdown</button>
<div ngbDropdownMenu aria-labelledby="dropdownMenu">
<button ngbDropdownItem>Action - 1</button>
<button ngbDropdownItem>Another Action</button>
<button ngbDropdownItem>Something else is here</button>
</div>
</div>
navbar.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-navbar',
templateUrl: './navbar.component.html'
})
export class NavbarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
我尝试在一些父级组件中使用,如 app.component.ts
<app-navbar></app-navbar>
看起来导航条组件需要 NgbDropdownModule
如果是这种情况,你会看到这样的消息:"你的名字是什么?ngbDropdown
未知元素",在控制台