Reputation: 36289
I have the following HTML:
<input class="user" ng-model="user" />
<div class="matches">
<div class="match" ng-repeat="match in matches | filter:user" ng-bind="match"></div>
</div>
I only want to show .matches
IF you are typing and searching for a user
. Otherwise, I don't want to show the field. But the input
field is always displaying the user
(so I can't use the fact that the input is empty or not).
Is there a way I can use the fact that the input
is focused directly? Right now, I manually update a value ng-if="isFocused"
when you focus in and out.
Upvotes: 4
Views: 6886
Reputation: 863
check this
<input class="user" ng-model="user" />
<div class="matches">
<div class="match" ng-if="user!=''" ng-repeat="match in matches | filter:user" ng-bind="match"></div>
</div>
Upvotes: 1
Reputation: 31761
<input type="text" ng-focus="focused = true" ng-blur="focused = false" />
<p ng-if="focused">focused!</p>
Upvotes: 19