html:
<div style='width:450px;'>
<div style='float:right;'>
<input ng-model='search' />
</div>
<div style='float:right;'>Search:</div>
</div>
<div style='width:450px;'>
<div>Logan Cale</div>
<div>Darien Fawkes</div>
<div>John Crichton</div>
<div>Michael Scofield</div>
<div>John Wick</div>
</div>
不知何故,我需要隐藏/显示 div
block ,其名称基于用户在 input
中输入的值。有什么简单的方法吗?
最佳答案
示例:
<div style='width:450px;'>
<div style='float:right;'>
<input ng-model='search' />
</div>
<div style='float:right;'>Search:</div>
</div>
<div style='width:450px;' ng-hide="search == 'hi'">
<div>Logan Cale</div>
<div>Darien Fawkes</div>
<div>John Crichton</div>
<div>Michael Scofield</div>
<div>John Wick</div>
</div>
现在在输入中输入“hi”以隐藏底部 div
关于javascript - 如何通过 ng-model 搜索 html 中的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33878842/