Good day Community, I have a problem with binding interpolated data/value with [ngModel], I would like to send the interpolated data to my database so i can get it and use it, but its sending and returning returning an empty string. My cart.component.html
<div class="col-5 col-md-6">
<h5>
<input type="text" class="form-control user-address goat"
name="item" placeholder="" [value]= "item.title" [(ngModel)]="cart.item.title" required >
<a routerLink="/products/shopping-hub/{{ item._id }}">{{ item.title }}</a>
</h5>
<p class="m-0">
<input type="text" class="form-control user-address goat"
name="owner" placeholder="" [value]= "item.owner.name" [(ngModel)]="cart.item.owner.name" required >
<small class="text-muted">{{ item.owner.name }}</small>
</p>
<p class="m-0">
<input type="text" class="form-control user-address goat"
name="category" placeholder="" [value]= "cart.item.category.name" [(ngModel)]="item.catgory.name" required >
<small class="text-muted">{{ item.category.name }}</small>
</p>
<a class="text-danger" (click)="removeProduct(i, item)">Remove from Cart</a>
</div>
<div class="col-1 col-md-2">
<input type="number" id="price" class="form-control user-address goat"
name="price" placeholder="" [value]= "price" [(ngModel)]="cart.item.price" required >
<h6 class="font-weight-bold text-danger"> ₦{{item.price}}</h6>
</div>
and my cart.component.ts
cart = {
item.title: [],
item.owner.name:[],
item.category.name:[],
item.price: [],
async checkout() {
this.btnDisabled = true;
try {
if (this.validate()) {
const data = await this.rest.post(
'http://localhost:3030/api/cart',
this.cart
); console.log('this.cart');
data['success']
? this.router.navigate(['/products/buynow/deliveryaddress/check-out'])
.then(() => this.data.success(data['message']))
.catch(error => this.data.error(error))
: this.data.error(data['message']);
} else {
this.btnDisabled = false;
}
} catch (error) {
this.data.error(error);
}
}
Thank you
import { FormsModule } from '@angular/forms';in your app module?let cart = { item: {title: []}}Also, can you see if there are any errors in the console?