我目前正在处理购物车,我想将在购物车页面上输入的数量和其他数据传递到结帐页面。我尝试了不同的方法,但我无法得到它。
这是我的Cart.component.ts
export class CartComponent implements OnInit {
@Input()
@Output() quantityChange = new EventEmitter();
constructor(
private data: DataService,
private rest: RestApiService,
private router: Router,
) {}
async ngOnInit() {
this.cartItems.forEach(data => {
this.quantities.push(1);
});
}
valueChanged(){
this.quantities = this.quantities
this.quantityChange.emit(this.quantities)
}
和我的cart.component.html
<div class="col-1 mt-5 mt-md-0 p-0 induc">
<input type="number" class="form-control text-left boy"
[(ngModel)]="quantities[i]">
</div>
...
<h5 class="text-right">Total:
<span class="ml-1 font-weight-bold text-danger"> ₦ {{ cartTotal}}
</span>
</h5>
谢谢