Data not coming in form when clicked in Edit button in angular










1














The data that is passed to assignmentAudit.component.ts when Edit Button is clicked is :



onEdit(nas:any)
console.log(nas);

this.assignmentAudit.auditorGroupNo=nas.assignmentAudit[0].auditorGroup.groupDesc;
this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate;
this.assignmentAudit.id=nas.assignmentAudit[0].id;
this.assignmentAudit.selectionNo=nas.selectionId;
this.assignmentAudit.magNo=0;




The console.log(nas); data is:
enter image description here



I have the form which has two input field is :



<form name="form" #f="ngForm" (ngSubmit)="f.form.valid && onSubmit()" novalidate class="">
<div class="form-group row">
<div class="col-md-6">
<label for="auditorGroup">Auditor Group</label>
<select class="form-control" id="auditorGroup" required [(ngModel)]="assignmentAudit.auditorGroupNo" name="auditorGroup"
#auditorGroup="ngModel"
[ngClass]=" 'is-invalid': f.submitted && auditorGroup.invalid "
required
>
<option *ngFor="let title of auditorgroups" [value]="title.auditorGroupId">title.groupDesc</option>
</select>
<div *ngIf="f.submitted && auditorGroup.invalid" class="invalid-input">
<div *ngIf="auditorGroup.errors?.required">Auditor Group is required</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="assignmentDate">Assignment Date</label>
<input type="date" id="assignmentDate" class="form-control" name="assignmentDate" placeholder="Please enter the Assignment Date" [(ngModel)]="assignmentAudit.assignmentDate" #assignmentDate="ngModel"
[ngClass]=" 'is-invalid': f.submitted && assignmentDate.invalid "
required />
<div *ngIf="f.submitted && assignmentDate.invalid" class="invalid-input">
<div *ngIf="assignmentDate.errors?.required">Assignment Date is required</div>
</div>
</div>
</div>
</div>
<button type="submit" style="margin-bottom: 50px;" class="btn btn-success pull-right">Submit</button>
</form>


The forms look simple as :



enter image description here



The action i need is :
enter image description here



I have binded the data using [(ngModel)]="assignmentAudit.assignmentDate" in form and when i put the value on after button click on onEdit() operation this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate; as it should be binded bidirectionally,the data is not showing automatically in form . What is the problem?










share|improve this question



















  • 1




    Are you able to create a StackBlitz that reproduces the problem?
    – user184994
    Nov 12 at 8:52










  • Do you have just one component for this ?
    – Sunil Singh
    Nov 12 at 9:17










  • yes i have single component
    – ashwin karki
    Nov 12 at 9:25










  • please post auditorgroups
    – firegloves
    Nov 12 at 9:35















1














The data that is passed to assignmentAudit.component.ts when Edit Button is clicked is :



onEdit(nas:any)
console.log(nas);

this.assignmentAudit.auditorGroupNo=nas.assignmentAudit[0].auditorGroup.groupDesc;
this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate;
this.assignmentAudit.id=nas.assignmentAudit[0].id;
this.assignmentAudit.selectionNo=nas.selectionId;
this.assignmentAudit.magNo=0;




The console.log(nas); data is:
enter image description here



I have the form which has two input field is :



<form name="form" #f="ngForm" (ngSubmit)="f.form.valid && onSubmit()" novalidate class="">
<div class="form-group row">
<div class="col-md-6">
<label for="auditorGroup">Auditor Group</label>
<select class="form-control" id="auditorGroup" required [(ngModel)]="assignmentAudit.auditorGroupNo" name="auditorGroup"
#auditorGroup="ngModel"
[ngClass]=" 'is-invalid': f.submitted && auditorGroup.invalid "
required
>
<option *ngFor="let title of auditorgroups" [value]="title.auditorGroupId">title.groupDesc</option>
</select>
<div *ngIf="f.submitted && auditorGroup.invalid" class="invalid-input">
<div *ngIf="auditorGroup.errors?.required">Auditor Group is required</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="assignmentDate">Assignment Date</label>
<input type="date" id="assignmentDate" class="form-control" name="assignmentDate" placeholder="Please enter the Assignment Date" [(ngModel)]="assignmentAudit.assignmentDate" #assignmentDate="ngModel"
[ngClass]=" 'is-invalid': f.submitted && assignmentDate.invalid "
required />
<div *ngIf="f.submitted && assignmentDate.invalid" class="invalid-input">
<div *ngIf="assignmentDate.errors?.required">Assignment Date is required</div>
</div>
</div>
</div>
</div>
<button type="submit" style="margin-bottom: 50px;" class="btn btn-success pull-right">Submit</button>
</form>


The forms look simple as :



enter image description here



The action i need is :
enter image description here



I have binded the data using [(ngModel)]="assignmentAudit.assignmentDate" in form and when i put the value on after button click on onEdit() operation this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate; as it should be binded bidirectionally,the data is not showing automatically in form . What is the problem?










share|improve this question



















  • 1




    Are you able to create a StackBlitz that reproduces the problem?
    – user184994
    Nov 12 at 8:52










  • Do you have just one component for this ?
    – Sunil Singh
    Nov 12 at 9:17










  • yes i have single component
    – ashwin karki
    Nov 12 at 9:25










  • please post auditorgroups
    – firegloves
    Nov 12 at 9:35













1












1








1







The data that is passed to assignmentAudit.component.ts when Edit Button is clicked is :



onEdit(nas:any)
console.log(nas);

this.assignmentAudit.auditorGroupNo=nas.assignmentAudit[0].auditorGroup.groupDesc;
this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate;
this.assignmentAudit.id=nas.assignmentAudit[0].id;
this.assignmentAudit.selectionNo=nas.selectionId;
this.assignmentAudit.magNo=0;




The console.log(nas); data is:
enter image description here



I have the form which has two input field is :



<form name="form" #f="ngForm" (ngSubmit)="f.form.valid && onSubmit()" novalidate class="">
<div class="form-group row">
<div class="col-md-6">
<label for="auditorGroup">Auditor Group</label>
<select class="form-control" id="auditorGroup" required [(ngModel)]="assignmentAudit.auditorGroupNo" name="auditorGroup"
#auditorGroup="ngModel"
[ngClass]=" 'is-invalid': f.submitted && auditorGroup.invalid "
required
>
<option *ngFor="let title of auditorgroups" [value]="title.auditorGroupId">title.groupDesc</option>
</select>
<div *ngIf="f.submitted && auditorGroup.invalid" class="invalid-input">
<div *ngIf="auditorGroup.errors?.required">Auditor Group is required</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="assignmentDate">Assignment Date</label>
<input type="date" id="assignmentDate" class="form-control" name="assignmentDate" placeholder="Please enter the Assignment Date" [(ngModel)]="assignmentAudit.assignmentDate" #assignmentDate="ngModel"
[ngClass]=" 'is-invalid': f.submitted && assignmentDate.invalid "
required />
<div *ngIf="f.submitted && assignmentDate.invalid" class="invalid-input">
<div *ngIf="assignmentDate.errors?.required">Assignment Date is required</div>
</div>
</div>
</div>
</div>
<button type="submit" style="margin-bottom: 50px;" class="btn btn-success pull-right">Submit</button>
</form>


The forms look simple as :



enter image description here



The action i need is :
enter image description here



I have binded the data using [(ngModel)]="assignmentAudit.assignmentDate" in form and when i put the value on after button click on onEdit() operation this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate; as it should be binded bidirectionally,the data is not showing automatically in form . What is the problem?










share|improve this question















The data that is passed to assignmentAudit.component.ts when Edit Button is clicked is :



onEdit(nas:any)
console.log(nas);

this.assignmentAudit.auditorGroupNo=nas.assignmentAudit[0].auditorGroup.groupDesc;
this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate;
this.assignmentAudit.id=nas.assignmentAudit[0].id;
this.assignmentAudit.selectionNo=nas.selectionId;
this.assignmentAudit.magNo=0;




The console.log(nas); data is:
enter image description here



I have the form which has two input field is :



<form name="form" #f="ngForm" (ngSubmit)="f.form.valid && onSubmit()" novalidate class="">
<div class="form-group row">
<div class="col-md-6">
<label for="auditorGroup">Auditor Group</label>
<select class="form-control" id="auditorGroup" required [(ngModel)]="assignmentAudit.auditorGroupNo" name="auditorGroup"
#auditorGroup="ngModel"
[ngClass]=" 'is-invalid': f.submitted && auditorGroup.invalid "
required
>
<option *ngFor="let title of auditorgroups" [value]="title.auditorGroupId">title.groupDesc</option>
</select>
<div *ngIf="f.submitted && auditorGroup.invalid" class="invalid-input">
<div *ngIf="auditorGroup.errors?.required">Auditor Group is required</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="assignmentDate">Assignment Date</label>
<input type="date" id="assignmentDate" class="form-control" name="assignmentDate" placeholder="Please enter the Assignment Date" [(ngModel)]="assignmentAudit.assignmentDate" #assignmentDate="ngModel"
[ngClass]=" 'is-invalid': f.submitted && assignmentDate.invalid "
required />
<div *ngIf="f.submitted && assignmentDate.invalid" class="invalid-input">
<div *ngIf="assignmentDate.errors?.required">Assignment Date is required</div>
</div>
</div>
</div>
</div>
<button type="submit" style="margin-bottom: 50px;" class="btn btn-success pull-right">Submit</button>
</form>


The forms look simple as :



enter image description here



The action i need is :
enter image description here



I have binded the data using [(ngModel)]="assignmentAudit.assignmentDate" in form and when i put the value on after button click on onEdit() operation this.assignmentAudit.assignmentDate=nas.assignmentAudit[0].auditorGroup.assignmentDate; as it should be binded bidirectionally,the data is not showing automatically in form . What is the problem?







javascript angular angular6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 8:58

























asked Nov 12 at 8:41









ashwin karki

1929




1929







  • 1




    Are you able to create a StackBlitz that reproduces the problem?
    – user184994
    Nov 12 at 8:52










  • Do you have just one component for this ?
    – Sunil Singh
    Nov 12 at 9:17










  • yes i have single component
    – ashwin karki
    Nov 12 at 9:25










  • please post auditorgroups
    – firegloves
    Nov 12 at 9:35












  • 1




    Are you able to create a StackBlitz that reproduces the problem?
    – user184994
    Nov 12 at 8:52










  • Do you have just one component for this ?
    – Sunil Singh
    Nov 12 at 9:17










  • yes i have single component
    – ashwin karki
    Nov 12 at 9:25










  • please post auditorgroups
    – firegloves
    Nov 12 at 9:35







1




1




Are you able to create a StackBlitz that reproduces the problem?
– user184994
Nov 12 at 8:52




Are you able to create a StackBlitz that reproduces the problem?
– user184994
Nov 12 at 8:52












Do you have just one component for this ?
– Sunil Singh
Nov 12 at 9:17




Do you have just one component for this ?
– Sunil Singh
Nov 12 at 9:17












yes i have single component
– ashwin karki
Nov 12 at 9:25




yes i have single component
– ashwin karki
Nov 12 at 9:25












please post auditorgroups
– firegloves
Nov 12 at 9:35




please post auditorgroups
– firegloves
Nov 12 at 9:35

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258457%2fdata-not-coming-in-form-when-clicked-in-edit-button-in-angular%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258457%2fdata-not-coming-in-form-when-clicked-in-edit-button-in-angular%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto