'How to assign give value to an array entity in interface in angular?
This i how I am calling a patch api in angular using an interface named Create
1> This is my apiService.ts code
const postData : Create = {
"address": {
"city": "string",
"addressDetails": "string",
"pincode": "string",
"state": "string",
"country": "string"
},
"bankName": "string",
"branch": "string",
}
2> This is my Component.ts code
getPatchBankAPI(postData : Create , postForm : NgForm){
this.patchService.getPatchBank(
postData.bankName,
postData.branch,
postData.address,
)
3> This is my HTML code
<div class="col-md-6">
<div class="form-row">
<div class="value">
<div class="input-group">
<input class="input--style-5" type="text" class="form-control"
id="bankName"
required
ngModel
name="bankName" placeholder="Bank Name">
</div>
</div>
</div></div>
<div class="col-md-6">
<div class="form-row">
<div class="value">
<div class="input-group">
<input class="input--style-5" type="text" class="form-control"
id="branch"
required
ngModel
name="branch" placeholder="Bank Branch">
</div>
</div>
</div></div>
<div class="col-md-6">
<div class="form-row">
<div class="value">
<div class="input-group">
<input class="input--style-5" type="text" class="form-control"
id=" city "
required
ngModel
name=" city " placeholder="Bank Address">
</div>
</div>
</div></div>
Now my problem is that If I want to take city name as an input then what should I write in : id=" " required ngModel name=" " id required ng model and name ?? Like address.city or directly city , I have tried directly writing city but my api is not accepting it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
