我只想在满足输入框内的特定条件时才在 html 中显示一些文本。否则,隐藏它。我正在使用 AngularJS。下面是我的 html 代码。
<form novalidate="" class="simple-form">conditional_number
<input type="text" ng-model="conditional_number " ng-change="search_number()"/>
如果输入框中的conditional_number超过5,我希望显示文本Text to appear if condition is met
。
在 AngularJS 中,有 ng-switch、ng-hide/ng-show、ng-if
等等。我不知道哪个是最合适的。如何在 AngularJS 中适本地做到这一点?
最佳答案
您可以使用 ng-show
简单地实现它
看看这个
<form novalidate="" class="simple-form">
<input name="myfield" ng-model="conditional_number" ng-minlength="5" ng-change="search_number()>
<span ng-show="conditional_number.length>5">Good boy!</span>
</form>
关于javascript - 在 AngularJS 中满足特定条件时如何在 html 中显示一些文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23537970/