Angular6 forms automatically fill in data

  • template code description:
    Angular6 response form has two FormControl, indicating name and age:
    name: < input type= "text" formControlName= "name" > < / div >
    Age: < input type= "text" formControlName= "age" > < / div >
  • what I want to achieve:
    when you open the page where the form is located, the instance of an entity class in this page has been assigned.
    requires that when you open the page where the form is located, fill in the corresponding data in the instance
    for example:
    when you open the page where the form is located, instance = {name:" Zhang San", age:15}
    , then the two input are filled in turn: Zhang San, 15
  • .
  • ask for help:
    I don"t know if there is a clear description above, it is best to provide code, and if not, it is also good to provide ideas.
    Thank you very much!
Jun.18,2021

set the value of formGroup directly after the formGroup is instantiated or assigned.

instance = { name:'', age:15 }
formGroup.patchValue({
    name:instance.name,
    age:instance.age
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36ecc-2b3b7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36ecc-2b3b7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?