If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.

742 views
Skip to first unread message

America News

unread,
Feb 20, 2018, 2:26:59 AM2/20/18
to Angular and AngularJS discussion
If ngModel is used within a form tag, either the name attribute must be set or the form
      control must be defined as 'standalone' in ngModelOptions.

      Example 1: <input [(ngModel)]="person.firstName" name="first">
      Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">
    at Function.TemplateDrivenErrors.missingNameException (forms.js:5889)
    at NgModel._checkName (forms.js:6242)
    at NgModel._checkForErrors (forms.js:6215)
    at NgModel.ngOnChanges (forms.js:6097)
    at checkAndUpdateDirectiveInline (core.js:12348)
    at checkAndUpdateNodeInline (core.js:13876)
    at checkAndUpdateNode (core.js:13819)
    at debugCheckAndUpdateNode (core.js:14712)
    at debugCheckDirectivesFn (core.js:14653)
    at Object.eval [as updateDirectives] (TrialComponent.html:52)
View_TrialComponent_0 @ TrialComponent.html:40
proxyClass @ compiler.js:14652
DebugContext_.logError @ core.js:14979
ErrorHandler.handleError @ core.js:1501
(anonymous) @ core.js:5898
ZoneDelegate.invoke @ zone.js:388
Zone.run @ zone.js:138
NgZone.runOutsideAngular @ core.js:4681
ApplicationRef.tick @ core.js:5898
(anonymous) @ core.js:5724
ZoneDelegate.invoke @ zone.js:388
onInvoke @ core.js:4733
ZoneDelegate.invoke @ zone.js:387
Zone.run @ zone.js:138
NgZone.run @ core.js:4550
next @ core.js:5724
schedulerFn @ core.js:4319
SafeSubscriber.__tryOrUnsub @ Subscriber.js:240
SafeSubscriber.next @ Subscriber.js:187
Subscriber._next @ Subscriber.js:128
Subscriber.next @ Subscriber.js:92
Subject.next @ Subject.js:56
EventEmitter.emit @ core.js:4299
checkStable @ core.js:4698
onHasTask @ core.js:4746
ZoneDelegate.hasTask @ zone.js:441
ZoneDelegate._updateTaskCount @ zone.js:461
Zone._updateTaskCount @ zone.js:285
Zone.runTask @ zone.js:205
drainMicroTaskQueue @ zone.js:595
Promise resolved (async)
scheduleMicroTask @ zone.js:578
ZoneDelegate.scheduleTask @ zone.js:410
Zone.scheduleTask @ zone.js:232
Zone.scheduleMicroTask @ zone.js:252
scheduleResolveOrReject @ zone.js:856
ZoneAwarePromise.then @ zone.js:946
PlatformRef.bootstrapModule @ core.js:5552
(anonymous) @ main.ts:12
../../../../../src/main.ts @ main.bundle.js:494
__webpack_require__ @ inline.bundle.js:55
0 @ main.bundle.js:509
__webpack_require__ @ inline.bundle.js:55
webpackJsonpCallback @ inline.bundle.js:26
(anonymous) @ main.bundle.js:1

Sander Elias

unread,
Feb 20, 2018, 2:29:48 AM2/20/18
to Angular and AngularJS discussion
Have you a question about that?
Reply all
Reply to author
Forward
0 new messages