Angular 2 Typescript: TypeError: this.validator is not a function

后端 未结 3 1584
野趣味
野趣味 2020-12-17 09:27

I\'m building a form with ControlGroup and I\'m loading a class object in it. However I\'m running into the error mentioned in the title half of the time. Some forms do load

3条回答
  •  猫巷女王i
    2020-12-17 10:06

    Create the form in the constructor. When Angular doesn't find the form on it's first attempt to resolve bindings then it doesn't work.

    this.userDetailForm just needs to be initialized with an empty group or with a few static controls. Then when the data arrives from the server, update the group by adding/removing controls and updating values.

提交回复
热议问题