简体   繁体   中英

I am having error when ever i am trying to call _id parameter in my angular front-end

EmployeeComponent.html: 11 ERROR TypeError: Cannot read property '_id' of undefined This is the error I am having when ever I try to call the id in my angular front-end

I have tried using ngIf but it still gives me error

Here I am having error

<div class="col s5" >
    <form   #employeeForm='ngForm'(ngSubmit)="onSubmit(employeeForm)">
        <input type="hidden" name="_id" #_id="ngModel"[(ngModel)]="employeeService.selectedEmployee._id" class="col s5">                           
                            <div class="row">
                                <div class="input-field col s12">
                                    <input type="text" name='name' #name='ngModel'[(ngModel)]="employeeService.selectedEmployee.name" placeholder="Enter Full name" class="input-field col s12" required>
                                    <label >Name :
                                        <label class="red-text">*</label>
                                    </label>
                                </div>                               
                            </div>

According to your code of just Angular, their can be many possibilities. One would be that your backend would not have sent you _id to you in frontend. first just verify that you are getting the proper data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM