Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a `#` attribute do in HTML?

I am writing a handler to do something to some element when a user clicks on a different element.

At first I had the following (This is using Angular2 but I suspect the only different is how the onclick event is handled):

        <span>
            <input type="text" id="bioName">
        </span>
        <span class="icon-pencil" (click)="editField(bioName);"></span>

...but this didn't work. I then found an example that identified the input field differently, and this did work for me. It was as follows:

        <span>
            <input type="text" #bioName>
        </span>
        <span class="icon-pencil" (click)="editField(bioName);"></span>

Unfortunately I can't find anything that explains this. Searching for "hash" and "pound" with HTML and Javascript yield too many results that have nothing to do with this in the subject area.

So what does # do in this case? Can id not be used to obtain a reference to the DOM element when setting up an event handler? What is this called so I can google it and read the appropriate documentation?

like image 808
WillyC Avatar asked Oct 31 '16 22:10

WillyC


People also ask

What the Fox say Meaning?

Speaking of the meaning of the song, Vegard characterizes it as coming from "a genuine wonder of what the fox says, because we didn't know". Although interpreted by some commentators as a reference to the furry fandom, the brothers have stated they did not know about its existence when producing "The Fox".

How can I find a song by the sound?

On your phone, touch and hold the Home button or say "Hey Google." Ask "What's this song?" Play a song or hum, whistle, or sing the melody of a song. Hum, whistle, or sing: Google Assistant will identify potential matches for the song.

What does the fox say for real?

One of the most common fox vocalizations is a raspy bark. Scientists believe foxes use this barking sound to identify themselves and communicate with other foxes. Another eerie fox vocalization is a type of high-pitched howl that's almost like a scream.

Is what does the fox say a book?

Now, the brothers have taken their fun lyrics and have paired them with Svein Nyhus's playful illustrations for a whole new take on the fox's unique way of speaking. What Does the Fox Say? is Ylvis's first picture book. Learn more at Ylvis.com.


1 Answers

This is Angular2 specific, regular HTML doesn't recognize this syntax, i.e. you have to use id="bioName" in order to access the tag with CSS/JavaScript.

Here is more information on how to use # in Angular2.

like image 80
Rok Povsic Avatar answered Oct 09 '22 11:10

Rok Povsic