gpt4 book ai didi

angular - 为循环中的每个 添加 ngx-bootstrap 的弹出窗口

转载 作者:太空狗 更新时间:2023-10-29 18:19:27 26 4
gpt4 key购买 nike

我正在尝试使用带有来自循环变量的数据的模板来显示弹出窗口,但我遇到了这些错误:

There is no directive with "exportAs" set to "bs-popover" ("template>
<span [popover]="popTemplate" popoverTitle="Anomalies" triggers="" [ERROR ->]#pop="bs-popover"></span>
<span *ngIf="vehicle.anomalies.length > 0" class="ba"): ng:///VehiclesModule/VehiclesSearchComponent.html@61:89
Can't bind to 'popover' since it isn't a known property of 'span'. ("
</ul>
</ng-template>
<span [ERROR ->][popover]="popTemplate" popoverTitle="Anomalies" triggers="" #pop="bs-popover"></span>
"): ng:///VehiclesModule/VehiclesSearchComponent.html@61:28
Error: Template parse errors:
There is no directive with "exportAs" set to "bs-popover" ("template>
<span [popover]="popTemplate" popoverTitle="Anomalies" triggers="" [ERROR ->]#pop="bs-popover"></span>
<span *ngIf="vehicle.anomalies.length > 0" class="ba"): ng:///VehiclesModule/VehiclesSearchComponent.html@61:89
Can't bind to 'popover' since it isn't a known property of 'span'. ("
</ul>
</ng-template>
<span [ERROR ->][popover]="popTemplate" popoverTitle="Anomalies" triggers="" #pop="bs-popover"></span>
"): ng:///VehiclesModule/VehiclesSearchComponent.html@61:28

我的组件 HTML 是这样的:

<table class="table table-bordered table-striped table-sm table-hover">
<thead>
<tr>
<th>
<input #chkAll type="checkbox" (click)="selectAll(chkAll.checked)" />
</th>
<th>Chassis</th>
<th>Última Atualização</th>
<th>MVS</th>
<th>Pátio</th>
<th>Localização</th>
<th class="actions-col-2"></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let vehicle of vehicles; let idx = index">
<td>
<input type="checkbox" id="vehicle-{{vehicle.id}}" name="vehicle-select" [(ngModel)]="vehicles[idx].checked" value="{{vehicle.id}}"
/>
</td>
<td>{{vehicle.chassis}}</td>
<td>{{vehicle.lastUpdate || '' | amFromUtc | amDateFormat: 'DD/MM/YYYY'}}</td>
<td>{{vehicle.mvsDescription}}</td>
<td>{{vehicle.yard.description}}</td>
<td>{{vehicle.location}}</td>
<td>

<ng-template #popTemplate>
<ul *ngFor="let anomaly of vehicle.anomalies">
<li>
<b>Componente:</b> {{anomaly.componentId}}
<b>Posição:</b> {{anomaly.tesisPosition}}
<b>Defeito:</b> {{anomaly.tesisDefect}}</li>
</ul>
</ng-template>
<span [popover]="popTemplate" popoverTitle="Anomalies" triggers="" #pop="bs-popover"></span>
<span *ngIf="vehicle.anomalies.length > 0" class="badge badge-pill badge-danger" (mouseenter)="pop.show()" (mouseleave)="pop.hide()">{{vehicle.anomalies.length}}</span>

</tr>

</tbody>
</table>

PS:我已经将 PopoverModule 添加到 AppModule 的导入中。

最佳答案

确保将 PopoverModule 导入到声明了 VehiclesSearchComponent 的模块中。

@NgModule({
// ...
imports: [PopoverModule], <----
declarations: [VehiclesSearchComponent],
})
export class NameModule {
}

关于angular - 为循环中的每个 <span> 添加 ngx-bootstrap 的弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47534368/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com