angular6 cannot set the value of ngForm from component.tsAngular6, Cannot add new dataAngular6 how to keep adding dropdown with selected valuesHow to iterate the keys and values in Angular6Angular6 :How to iterate the keys and values without Pipecheck if more than 1 value in an array in angular6how to edit template driven form values in angular6How to set default values in ng-select in angular6?Set value for angular6 select option using reactive FormGroup or FormControlNameHow to set value to a Reactive Form control in Angular6?

SQL Server table with 4,000,000 rows is 40GB

Is there a sentence that begins with “them”?

Have there been any countries that voted themselves out of existence?

How can "life" insurance prevent the cheapening of death?

How should we understand "unobscured by flying friends" in this context?

Will replacing a fake visa with a different fake visa cause me problems when applying for a legal study permit?

How flexible are number-of-pages submission guidelines for conferences?

Why does F + F' = 1?

Should I use my toaster oven for slow roasting?

How to create a list of dictionaries from a dictionary with lists of different lengths

Georgian capital letter “Ⴒ” (“tar”) in pdfLaTeX

What is this dollar sign ($) icon in my Menu Bar?

Why would "an mule" be used instead of "a mule"?

How do I politely hint customers to leave my store, without pretending to need leave store myself?

Expected value until a success?

SCOTUS - Can Congress overrule Marbury v. Madison by statute?

What's the biggest difference between these two photos?

Where does the expression "triple-A" comes from?

Are programming languages necessary/useful for operations research practitioner?

Could the government trigger by-elections to regain a majority?

Writing a love interest for my hero

Are there take-over requests from autopilots?

Wrathful Smite, and the term 'Creature'

Can board a plane to Cameroon without a Cameroonian visa?



angular6 cannot set the value of ngForm from component.ts


Angular6, Cannot add new dataAngular6 how to keep adding dropdown with selected valuesHow to iterate the keys and values in Angular6Angular6 :How to iterate the keys and values without Pipecheck if more than 1 value in an array in angular6how to edit template driven form values in angular6How to set default values in ng-select in angular6?Set value for angular6 select option using reactive FormGroup or FormControlNameHow to set value to a Reactive Form control in Angular6?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















i am developing an basic angular 6 application that fetches the data, display it in the table, each row has delete, edit button this is one component 'detail list', i have another component as 'detail component' that are having controls to add the record in the table, i am fetching the data from the webapi, adding the record and deleting the record using the same webapi, they all are working fine, now i want to edit the record from the table, i am using the same webapi to fetch the data, webapi returning the record, i want to display this record's data in the 'detail component', the same component that is used to add the record, so at the component i am calling ngAfterViewInit()



>



 ngAfterViewInit() 
this.service.change.subscribe((data: Patient) =>
alert('in the detail component of ngAfterViewInit');
console.log(data);
this.ModelChange(data);
) ;



and the code for the ModelChange is as follows




ModelChange(data: Patient)
this.form.controls['PatientCode'].setValue(data.PatientCode);






and my html is like







<form #form="ngForm" autocomplete="on" (submit)="OnSubmit(form)">
<div class="row">
<div class="form-group">
<input name="PatientCode" [(ngModel)]="PatientCode"class="form-control" placeholder ="Patient Code" (ngModelChange)="ModelChange(event)" required>

</div>
<div class="col-md -3 form-group">
<input name="FirstName" [(ngModel)] ="FirstName" class="form-control" placeholder="First Name" required>

</div>
<div class=" col-md-5 form-group">
<input name="LastName" [(ngModel)]="LastName" class="form-control" placeholder="Last Name" required>

</div>
</div>
<div class="row">
<div class="form-group">
<input name="MRN" class="form-control" [(ngModel)]="MRN" placeholder="MRN" required>

</div>
<div class="col-md-3 form-group">
<!--<input name="DateOfBirth" class="form-control" placeholder="Date of Birth">-->
<ejs-datepicker name="DateOfBirth" [(ngModel)]="DateOfBirth" id='datepicker' placeholder='Enter Date Of Birth' [value]='value' [min]='minDate' [max]='maxDate'></ejs-datepicker>

</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<button type="submit" (click)="AddPatient(p)" class="btn btn-success center-block "> Add Patient</button>
</div>
<div class="col-md-13">
<button type="submit" (click)="EditPatient(p)" class="btn btn-success center-block "> Edit Patient</button>
</div>

</div>
</form>


at the console i am getting error that cannot Cannot read property 'controls' of undefined



Please help me out what is the correct way of setting the control property with the fetched data










share|improve this question






























    1















    i am developing an basic angular 6 application that fetches the data, display it in the table, each row has delete, edit button this is one component 'detail list', i have another component as 'detail component' that are having controls to add the record in the table, i am fetching the data from the webapi, adding the record and deleting the record using the same webapi, they all are working fine, now i want to edit the record from the table, i am using the same webapi to fetch the data, webapi returning the record, i want to display this record's data in the 'detail component', the same component that is used to add the record, so at the component i am calling ngAfterViewInit()



    >



     ngAfterViewInit() 
    this.service.change.subscribe((data: Patient) =>
    alert('in the detail component of ngAfterViewInit');
    console.log(data);
    this.ModelChange(data);
    ) ;



    and the code for the ModelChange is as follows




    ModelChange(data: Patient)
    this.form.controls['PatientCode'].setValue(data.PatientCode);






    and my html is like







    <form #form="ngForm" autocomplete="on" (submit)="OnSubmit(form)">
    <div class="row">
    <div class="form-group">
    <input name="PatientCode" [(ngModel)]="PatientCode"class="form-control" placeholder ="Patient Code" (ngModelChange)="ModelChange(event)" required>

    </div>
    <div class="col-md -3 form-group">
    <input name="FirstName" [(ngModel)] ="FirstName" class="form-control" placeholder="First Name" required>

    </div>
    <div class=" col-md-5 form-group">
    <input name="LastName" [(ngModel)]="LastName" class="form-control" placeholder="Last Name" required>

    </div>
    </div>
    <div class="row">
    <div class="form-group">
    <input name="MRN" class="form-control" [(ngModel)]="MRN" placeholder="MRN" required>

    </div>
    <div class="col-md-3 form-group">
    <!--<input name="DateOfBirth" class="form-control" placeholder="Date of Birth">-->
    <ejs-datepicker name="DateOfBirth" [(ngModel)]="DateOfBirth" id='datepicker' placeholder='Enter Date Of Birth' [value]='value' [min]='minDate' [max]='maxDate'></ejs-datepicker>

    </div>
    </div>
    <div class="row">
    <div class="col-md-12 text-center">
    <button type="submit" (click)="AddPatient(p)" class="btn btn-success center-block "> Add Patient</button>
    </div>
    <div class="col-md-13">
    <button type="submit" (click)="EditPatient(p)" class="btn btn-success center-block "> Edit Patient</button>
    </div>

    </div>
    </form>


    at the console i am getting error that cannot Cannot read property 'controls' of undefined



    Please help me out what is the correct way of setting the control property with the fetched data










    share|improve this question


























      1












      1








      1








      i am developing an basic angular 6 application that fetches the data, display it in the table, each row has delete, edit button this is one component 'detail list', i have another component as 'detail component' that are having controls to add the record in the table, i am fetching the data from the webapi, adding the record and deleting the record using the same webapi, they all are working fine, now i want to edit the record from the table, i am using the same webapi to fetch the data, webapi returning the record, i want to display this record's data in the 'detail component', the same component that is used to add the record, so at the component i am calling ngAfterViewInit()



      >



       ngAfterViewInit() 
      this.service.change.subscribe((data: Patient) =>
      alert('in the detail component of ngAfterViewInit');
      console.log(data);
      this.ModelChange(data);
      ) ;



      and the code for the ModelChange is as follows




      ModelChange(data: Patient)
      this.form.controls['PatientCode'].setValue(data.PatientCode);






      and my html is like







      <form #form="ngForm" autocomplete="on" (submit)="OnSubmit(form)">
      <div class="row">
      <div class="form-group">
      <input name="PatientCode" [(ngModel)]="PatientCode"class="form-control" placeholder ="Patient Code" (ngModelChange)="ModelChange(event)" required>

      </div>
      <div class="col-md -3 form-group">
      <input name="FirstName" [(ngModel)] ="FirstName" class="form-control" placeholder="First Name" required>

      </div>
      <div class=" col-md-5 form-group">
      <input name="LastName" [(ngModel)]="LastName" class="form-control" placeholder="Last Name" required>

      </div>
      </div>
      <div class="row">
      <div class="form-group">
      <input name="MRN" class="form-control" [(ngModel)]="MRN" placeholder="MRN" required>

      </div>
      <div class="col-md-3 form-group">
      <!--<input name="DateOfBirth" class="form-control" placeholder="Date of Birth">-->
      <ejs-datepicker name="DateOfBirth" [(ngModel)]="DateOfBirth" id='datepicker' placeholder='Enter Date Of Birth' [value]='value' [min]='minDate' [max]='maxDate'></ejs-datepicker>

      </div>
      </div>
      <div class="row">
      <div class="col-md-12 text-center">
      <button type="submit" (click)="AddPatient(p)" class="btn btn-success center-block "> Add Patient</button>
      </div>
      <div class="col-md-13">
      <button type="submit" (click)="EditPatient(p)" class="btn btn-success center-block "> Edit Patient</button>
      </div>

      </div>
      </form>


      at the console i am getting error that cannot Cannot read property 'controls' of undefined



      Please help me out what is the correct way of setting the control property with the fetched data










      share|improve this question














      i am developing an basic angular 6 application that fetches the data, display it in the table, each row has delete, edit button this is one component 'detail list', i have another component as 'detail component' that are having controls to add the record in the table, i am fetching the data from the webapi, adding the record and deleting the record using the same webapi, they all are working fine, now i want to edit the record from the table, i am using the same webapi to fetch the data, webapi returning the record, i want to display this record's data in the 'detail component', the same component that is used to add the record, so at the component i am calling ngAfterViewInit()



      >



       ngAfterViewInit() 
      this.service.change.subscribe((data: Patient) =>
      alert('in the detail component of ngAfterViewInit');
      console.log(data);
      this.ModelChange(data);
      ) ;



      and the code for the ModelChange is as follows




      ModelChange(data: Patient)
      this.form.controls['PatientCode'].setValue(data.PatientCode);






      and my html is like







      <form #form="ngForm" autocomplete="on" (submit)="OnSubmit(form)">
      <div class="row">
      <div class="form-group">
      <input name="PatientCode" [(ngModel)]="PatientCode"class="form-control" placeholder ="Patient Code" (ngModelChange)="ModelChange(event)" required>

      </div>
      <div class="col-md -3 form-group">
      <input name="FirstName" [(ngModel)] ="FirstName" class="form-control" placeholder="First Name" required>

      </div>
      <div class=" col-md-5 form-group">
      <input name="LastName" [(ngModel)]="LastName" class="form-control" placeholder="Last Name" required>

      </div>
      </div>
      <div class="row">
      <div class="form-group">
      <input name="MRN" class="form-control" [(ngModel)]="MRN" placeholder="MRN" required>

      </div>
      <div class="col-md-3 form-group">
      <!--<input name="DateOfBirth" class="form-control" placeholder="Date of Birth">-->
      <ejs-datepicker name="DateOfBirth" [(ngModel)]="DateOfBirth" id='datepicker' placeholder='Enter Date Of Birth' [value]='value' [min]='minDate' [max]='maxDate'></ejs-datepicker>

      </div>
      </div>
      <div class="row">
      <div class="col-md-12 text-center">
      <button type="submit" (click)="AddPatient(p)" class="btn btn-success center-block "> Add Patient</button>
      </div>
      <div class="col-md-13">
      <button type="submit" (click)="EditPatient(p)" class="btn btn-success center-block "> Edit Patient</button>
      </div>

      </div>
      </form>


      at the console i am getting error that cannot Cannot read property 'controls' of undefined



      Please help me out what is the correct way of setting the control property with the fetched data







      angular6






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 7:35









      Sa faSa fa

      61 bronze badge




      61 bronze badge

























          0






          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/4.0/"u003ecc by-sa 4.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%2f55392291%2fangular6-cannot-set-the-value-of-ngform-from-component-ts%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392291%2fangular6-cannot-set-the-value-of-ngform-from-component-ts%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







          Popular posts from this blog

          1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          인천여자상업고등학교 목차 학교 연혁 설치 학과 학교 동문 참고 자료 각주 외부 링크 둘러보기 메뉴북위 37° 28′ 05″ 동경 126° 37′ 41″ / 북위 37.4680025° 동경 126.6279602°  / 37.4680025; 126.6279602인천여자상업고등학교“인천광역시립학교 설치조례 별표1”인천여자상업고등학교 홈페이지eheh문서를 완성해