Angular Core

Angular Core ngModel Name Property


This course has been updated! We now recommend you take the Angular 9 Fundamentals course.

Check out a free preview of the full Angular Core course:
The "ngModel Name Property" Lesson is part of the full, Angular Core course featured in this preview video. Here's what you'd learn in this lesson:

Lukas explains what is going on under the hood with the njModel name property.

Get Unlimited Access Now

Transcript from the "ngModel Name Property" Lesson

>> Speaker 1: I need to make one additional piece of commentary, here, that could trip you up.
>> Speaker 1: When you're using ngModel, so this is specifically a template driven form. So for most basic use cases, this is completely fine, that if you use an ngModel, that you must have a name property on that element or it will fall apart.

[00:00:29] Something under the hood allows angular to connect that. So you notice when I was on the slider, that I forgot to put the name on it. Everything else was working but that slider wasn't responding. So in order for ngModel to hook into and bind to a form element, it needs a name property.

[00:00:51] Which, really, the reason being, it's cuz it's attaching a top level form controller to the entire form, and then, essentially, keeping track of everything. And if that goes in a bad spot, then it will capture that.