My goal is to create a directive that incorporates a label and a text input field. The main requirement is for the label to be visible only when the input field is in focus or contains text. Below is the current code I am working with, which I aim to convert into a reusable directive for other fields.
<label class="text-field-top-label"></label>
<input type="email"
name="email"
ng-model="user.email"
ng-model-options="{updateOn: 'blur'}"
required
placeholder="Email address"/>
I am facing difficulty in this task because I cannot directly target the label or text field without assigning them specific IDs, which goes against my intention of creating a flexible directive. If you have any insights or suggestions on how to tackle this issue, I would greatly appreciate it.