I've been following the Angular2 tutorial https://angular.io/docs/ts/latest/tutorial/toh-pt6.html and found the following input element syntax (under the "Add a Hero" heading):
<input #heroName />
This is supposedly setting the id
attribute of the input
element, but I could not find this syntax in the HTML5 specification (https://www.w3.org/TR/html5/syntax.html#attributes-0).
Can anyone explain this syntax?
The input tag is used within < form> element to declare input controls that allow users to input data. An input field can be of various types depending upon the attribute type. The Input tag is an empty element which only contains attributes. For defining labels for the input element, < label> can be used.
The input element represents a typed data field, usually with a form control to allow the user to edit the data. The type attribute controls the data type (and associated control) of the element. It is an enumerated attribute.
It's not referring to the element id of html5. It's strictly related to angular2 and is a Template reference variable.
So, as said in the official documentation,
The hash (#) prefix to "phone" means that we're defining a phone variable.
In your case is not "phone", but "heroName".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With