Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

A "bug" in the official documentation for Angular2 template forms #3405

Description

@gregordotjs

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

In the official Angular2 documentation (form templates: https://angular.io/docs/ts/latest/guide/forms.html) after clicking "New hero", firstly the newHero function gets called and then the form resets. This firstly sets the model's properties to empty string, but after calling the reset function, the values are set to null. Which is in my opinion wrong (what if newHero function would set default values to some actual name? Then the reset function would override it with null value).

Expected behavior

Upon clicking new hero, the object would have properties with empty string values.

Minimal reproduction of the problem with instructions

Here's the example (clicking New Hero (official) causes the incorrect behavior and New Hero (alt) appears to work as expected): https://plnkr.co/edit/1w2SSv8qxpOCjfDaJxPz?p=preview

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

The documentation would correctly address the reset function and ngModel.

Please tell us about your environment:

Angular CLI project, Visual Studio Code, json-server

  • Angular version: 2.0.X

2.3.1

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome Version 56.0.2924.87

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    Typescript

  • Node (for AoT issues): node --version =
    v6.9.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions