Hi Everyone,
This is an error which occurs frequently in my project even though 'id' has
been declared in its respective class.I am not able to figure it out what
exactly is the issue....Here in my project when I go into editing any
particular page... using ngModel, I am trying to get the selected value
from a dropdown list and also value from a textbox. The value from the
textbox is displayed but the selected value from a dropdown is not seen
only the list of items is shown..It says that id of undefined.Can anyone
help me with it??Please check the code below..
Thanks & Regards,
Rakhee
ERROR TypeError: Cannot read property 'id' of undefined
at Object.eval [as updateRenderer] (ItemCategoryDetailComponent.html:82)
at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:13105)
at checkAndUpdateView (core.es5.js:12256)
at callViewAction (core.es5.js:12599)
at execEmbeddedViewsAction (core.es5.js:12557)
at checkAndUpdateView (core.es5.js:12252)
at callViewAction (core.es5.js:12599)
<div class="form-group col-md-6" >
<label for="category_name">Category Name</label>
<input
formControlName="category_name"
class="form-control"
id="category_name"
placeholder="Enter Item Name"
[(ngModel)]="category.category_name">
<!-- <div *ngIf="itemCategory.touched && itemCategory.invalid"class="alert
alert-danger">
<div *ngIf="itemCategory.errors.required">Category Name is required</div>
</div> -->{{ category.item_grp_id.group_name}}
</div>
<div class="form-group col-md-6">
<label for="item_grp_id">Group Name</label>
<select
formControlName="item_grp_id"
class="form-control select2"
id="item_grp_id"
style="width: 100%;"
(keydown) = "getAllGroups()"
(ngModelChange)="getAllGroups()"
[(ngModel)]="category">
<!-- <option value="" disabled></option> -->
<option>
{{ category.item_grp_id.group_name}}
</option>
<option *ngFor="let itemgroup of itemgroups"[value]="itemgroup.id"[selected
]="itemgroup.id === category.item_grp_id.id">
{{ itemgroup.group_name }}
</option>
</select>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.