angular: Update DOM when changing template in reactive form fails

I’m submitting a … (check one with “x”)

[ x ] bug report => search github for a similar issue or PR before submitting
[   ] feature request
[   ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Changing a reactive form template fails. When replacing the form, it throws an error: Error in ./App class App - inline template:0:6 caused by: control.registerOnChange is not a function

Expected behavior

It should not throw any error… and should change the template

Minimal reproduction of the problem with instructions

https://plnkr.co/edit/dJ1KyDLFDOOa1FUfWu5d?p=preview

Click on new template and check the console

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

NodeJS 7.4.0 running on Windows 10

  • Angular version: 2.4.7

  • Browser: Chrome 55 64bit

  • Language: Typescript

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 23 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@tbosch & @DzmitryShylovich 9 months now… any chance someone can look at this bug and fix it for v5? This is a real bug and it doesn’t even have the bug label.

Lets see, I’ll play a little bit “Product Manager” here

@ghetolay thinks:

I don’t think this is a bug, you can’t change a form, you build it only once at init.

@natcohen counters:

What I might have to do is to remove all the controls and build again…but why couldn’t I just change the form? This should definitely be supported!

And I want to ask:

When using plain ECMAScript within a browser, can I change a form at runtime (post-creation)?

If the answer is “no”, then Angular should provide it (to be stronger than ECMAScript)

If the answer is “yes”, then Angular must provide it, too, otherwise Angular is weaker than plain ECMAScript, which would be a shooting point (“What? Angular? Too restrictive, you even cannot modify a form at run-time.”).

As for this issue:

  • If this functionality is a should requirement, then this issue becomes a feature-request
  • If this functionality is a must requirement, thin this issue becomes a bug

(This classification should never take 3 months)

Either you want it or not: this is a Google led project, so one expects some level of professionalism here.

Am I wrong somewhere?

Accepting counters!

And bets!