Using Angular ngmodel without name attribute

I just read and study the Angular2 tutorial. It says: "Defining a name attribute is a requirement when using [(ngModel)] in conjunction with a form." However, the tutorial uses ngmodel without the name attribute here .

 <input [(ngModel)]="selectedHero.name" placeholder="name"/>

Could you explain why this works? Please note: I am new to angular as well as user interface

+4
source share
1 answer

I believe in your first link HERE they do not use the element <form></form>.

Because in your 2nd link HERE they say

Defining a name attribute is a requirement when using [(ngModel)] in combination with a form.

... . conclusion hero-form.component.html <form>, name.

, <form></form> , name , , , .

, , , , !

+1

Source: https://habr.com/ru/post/1656857/


All Articles