What does #id in input tag mean?

前端 未结 6 1205
挽巷
挽巷 2021-01-18 10:56

From this Angular.io tutorial, I show:


where I do not unde

6条回答
  •  长情又很酷
    2021-01-18 11:48

    Template Reference Variable using Select Box

     
    

    look at the code snippet, #myColor is a template reference variable. The selected value of select box can be accessed by myColor.value

    Template Reference Variable with NgForm

    how to access NgForm directive using template reference variable

    ngSubmit: It enables binding angular expressions to onsubmit event of the form. Here on form submit onSubmitPersonForm component method will be called.

    ngForm: It is the nestable alias of form directive

    Here we are using template reference variable for ngForm as #myForm="ngForm" . Now we can use myForm in place of ngForm such as to check form validity and we can also use it in our angular

    Template Reference Variable using Input Text Box

    Template reference variable is a variable using which we can access DOM properties. In our example, we are using following DOM properties of the input box.

    
    

    In the above input text box, #mobile is a template reference variable. To fetch DOM properties, we do as follows.

    mobile.placeholder: It will give placeholder of our text box if we have specified.

    mobile.value: It will give the value of our text box.

    mobile.type: It will give the type of input element. In our example type is text.

提交回复
热议问题