Skip to content

Error message when the form for ngFormModel is undefined is poor. #8136

@escardin

Description

@escardin

Steps to reproduce and a minimal demo of the problem
When a form is not provided to ngFormModel, the console error message does not describe the root cause. See plunk: http://plnkr.co/edit/Oyj4mq7C9e88AfsXr4M1?p=preview

What steps should we try in your demo to see the problem?
The issue is demonstrated on load. When you uncomment lines 34-36 of app.ts the failure goes away, indicating the cause is a missing form.
Current behavior

RIGINAL EXCEPTION: TypeError: Cannot read property 'validator' of undefinedBrowserDomAdapter.logError @ angular2.dev.js:23501
angular2.dev.js:23501 ORIGINAL STACKTRACE:BrowserDomAdapter.logError @ angular2.dev.js:23501
angular2.dev.js:23501 TypeError: Cannot read property 'validator' of undefined
    at NgFormModel.ngOnChanges (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:16731:73)
    at AbstractChangeDetector.ChangeDetector_App_0.detectChangesInRecordsInternal (viewFactory_App:45:59)
    at AbstractChangeDetector.detectChangesInRecords (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:8077:14)
    at AbstractChangeDetector.runDetectChanges (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:8060:12)
    at AbstractChangeDetector._detectChangesInViewChildren (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:8139:14)
    at AbstractChangeDetector.runDetectChanges (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:8064:12)
    at AbstractChangeDetector.detectChanges (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:8049:12)
    at ChangeDetectorRef_.detectChanges (https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:5180:16)
    at https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js:12682:27
    at Array.forEach (native)

Expected/desired behavior
A message indicating that no form was passed. Perhaps: 'ngFormModel is missing a form'

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