简体   繁体   English

HTML5输入语法

[英]HTML5 input syntax

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): 我一直在关注Angular2教程https://angular.io/docs/ts/latest/tutorial/toh-pt6.html并找到以下输入元素语法(在“Add a Hero”标题下):

<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 ). 这应该设置input元素的id属性,但我在HTML5规范( https://www.w3.org/TR/html5/syntax.html#attributes-0 )中找不到这种语法。

Can anyone explain this syntax? 有谁能解释这种语法?

It's not referring to the element id of html5. 它不是指html5的元素id。 It's strictly related to angular2 and is a Template reference variable . 它与angular2严格相关,是一个模板引用变量

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". 在你的情况下不是“电话”,而是“heroName”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM