I've got a directive that renders a simple searchbox - its HTML looks as follows:
<div class="search input-group"> <input type="text" ng-model="text" ng-change="onChange()" placeholder="Search here..." class="form-control"> <span class="input-group-btn"> <button class="btn btn-default glyphicon glyphicon-search"></button> </span> </div> All is well and working, I'm able to use it like this:
<searchbox ng-model="search" /> However, now I would like the searchbox to have autofocus in some cases, and in some cases not, for that, it would be neat to just be able to do:
<searchbox ng-model="search" autofocus /> and have that result in having the autofocus attribute carried over to the <input> tag within the directive. Is this possible? How would I go about doing that? Is there a way to carry over specific attributes over to a specific sub-element?