簡體   English   中英

除非AngularJS中有另一個元素,否則隱藏元素的最佳方法是什么?

[英]What would be the best way to hide an element unless a different element has focus in AngularJS?

基本上,我有一個搜索欄和預測顯示在它下面。 我希望隱藏預測,除非搜索欄有焦點。 有很多方法可以實現這一點,所以我想知道你認為最好的方法是什么?為什么?

您可以使用ng-hide和ng-focus: -

<input type="text" ng-focus="showme=true">
<div ng-hide="showme">

in controller 
$scope.showme=false;

plunker: - http://plnkr.co/edit/FHHeYRn8VGLx2tcMTF0M?p=preview

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM