【发布时间】:2016-11-04 03:39:04
【问题描述】:
我有一个 Angular 应用程序,一旦输入文本框中有这么多字符,它就会执行操作并在表格中显示数据。我试图弄清楚如何根据在输入框中输入的字符数来显示和隐藏表格。
<head>
<script>
angular.module('minLength', [])
.controller("SomeController ", ['$scope ', function($scope) {
$scope.minlength = 3;
}];
</script>
</head>
<div ng-controller="SomeController">
<input type="text" id="foo" name="input" ngMinLength="minlength" ng-keydown="some.operation()" ng-model="some.model">
<div id="table 1 >
<!--content -->
</div>
<div id="table 2">
<!-- content -->
</div>
</div>
有什么建议吗?我应该使用 ng-show 还是有更好的方法来做我想做的事情。
【问题讨论】:
-
ng-if="some.model.length > 42"等 -
您可以在用户输入一定数量的字符后尝试获取数据,然后将其设置在 $scope 和数据绑定到表格中,而不是显示或隐藏内容,如果您想同时显示两者表格,否则您可以使用任何 ng-switch、ng-show/ng-hide 或 ng-if 指令。
-
@raina77ow 成功了
标签: javascript jquery html css angularjs