我想打开一个属于单独组件的模态..我试了但是得到错误错误TypeError:无法读取属性'show'未定义
我的代码如下,
产品catalog.component.html
<app-cart-table-modal></app-cart-table-modal>
<button type="button" class="btn btn-primary relative waves-light" (click)="basicModal.show(); loadCart(26);" mdbWavesEffect>My Cart</button>
推车表modal.component.html
<div mdbModal #basicModal="mdb-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myBasicModalLabel" aria-hidden="true" [config]="{backdrop: false, ignoreBackdropClick: true}">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" aria-label="Close" (click)="basicModal.hide()">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title w-100" id="myModalLabel">
<i class="fa fa-cart-arrow-down fa-4x" aria-hidden="true"></i>
My Cart
</h4>
</div>
<div class="modal-body">
<!-- <table class="table table-sm table-striped"> -->
<table class="table table-striped">
<thead class="mdb-color darken-3">
<tr class="text-white">
<th>#</th>
<th>Product</th>
<th>Model</th>
<th>quantity</th>
<th>Unit Price</th>
<th>Discount</th>
<th>Total</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let cartitem of cartitems; let i = index">
<td>
<div class="checkbox">
<label><input type="checkbox" (change) = "checkMarkCartitem(cartitem.cartItemId)">{{i+1}}</label>
</div>
</td>
<td>{{cartitem.description}}</td>
<td>{{cartitem.modelNo}}</td>
<td><input type="number" class="form-control" (blur)="changequantity(cartitem.productId)"
value="{{cartitem.orderQuanity}}" size="16" [id]="'quantity' + cartitem.productId"></td>
<td>{{cartitem.unitPrice}}</td>
<td>{{cartitem.discountApplied}}</td>
<td>{{cartitem.totalItemAmountIncDiscount}}</td>
<td>
<div class="btn-group">
<button type="button" style="background-color: white"><i class="fa fa-close"
style="font-size:24px;color:red"></i></button>
</div>
</td>
</tr>
<tr>
<td colspan="6">Total</td>
<td>{{orderTotalAmount}}</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-light" aria-label="Close" (click)="basicModal.hide()" mdbWavesEffect>Close</button>
<button type="button" class="btn btn-primary relative waves-light" mdbWavesEffect (click) = "placeOrder();">Place Order</button>
</div>
</div>
</div>
</div>
任何帮助都会得到高度赞赏..在此先感谢..
答案 0 :(得分:0)
在 product-catalog.component.html 中替换:
<app-cart-table-modal></app-cart-table-modal>
使用:
<app-cart-table-modal mdbModal #basicModal="mdb-modal" class="modal fade" tabindex="-1"`role="dialog" aria-labelledby="myBasicModalLabel" aria-hidden="true" [config]="{backdrop:` `false, ignoreBackdropClick: true}"></app-cart-table-modal>
还在cart-table-modal.component.html中删除第一个标记为:
<div mdbModal #basicModal="mdb-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myBasicModalLabel" aria-hidden="true" [config]="{backdrop: false, ignoreBackdropClick: true}">