对无效的返回值应用ng类
apply ng class on invalid return value
我想将bootstrap has-error
类应用于控制器中方法的无效返回。但我的尝试似乎都没有奏效。以下是我的做法:
<form role="form" name="configForm">
<div class="form-group">
<label class="control-label">Not between</label>
<table class="table table-bordered table-hover table-condensed">
<tr style="font-style:italic; font-weight: bold">
<td style="width: 50%">Lower Bound</td>
<td style="width: 50%">Upper Bound</td>
</tr>
<tr ng-repeat="bounds in themeComponents.components[compKey].boundaries.notBetween">
<td>
<input name="betweenLowBound" class="form-control" ng-model="bounds.lower" ng-class="{'has-error' : checkBounds(bounds.lower, bounds.upper) == true }">
</td>
<td>
<input name="betweenUpperBound" class="form-control" ng-model="bounds.upper" ng-class="{'has-error' : checkBounds(bounds.lower, bounds.upper) == true }">
</td>
<td>
<button type="button" ng-click="removeEasingItem(compKey, bounds)" class="btn btn-sm btn-danger">
<i class="glyphicon glyphicon-remove-circle">
</i>
</button>
</td>
</tr>
</table>
</div>
</form>
这是我的简单值机控制器:
$scope.checkBounds = function (lower, upper) {
if(lower > upper)
return true;
return false;
}
此外,我如何将其设计为内联ng-if
表达式,而不是控制器中的方法?当upperbound
值大于lowerbound
时,我希望td-input
进入error
状态。。
使用ng类动态添加css:ng-class="{ 'has-error': bounds.lower > bounds.upper}"
相关文章:
- ng应用程序使脚本无限运行
- Angular ng控制器与ng应用程序冲突
- 在AngularJS中的另一个ng应用程序中使用来自一个ng程序的Cookie值
- 通过共享服务在两个不同ng应用程序中的控制器之间共享数据
- 如何在angularjs中按顺序执行多数据ng应用程序
- 如何在angular js的ng应用程序中以普通的htm显示标签
- 从angular js中的另一个ng应用程序调用方法
- 在全球范围内强制ng严格di,而不仅仅是在ng应用程序级别上
- AngularJS-ng应用程序不工作,如果不是emplty
- 如何使用附加到html标签的嵌套ng应用程序将一个基于angularjs的SPA包含到另一个基于angularjs
- 多个ng应用程序是如何在angular中工作的(为什么会有这样的行为?)
- 为什么一个ng应用程序一次工作
- ng包含不'ng应用程序获得名称时不起作用
- 我该如何命名angular Js的ng应用程序
- angular.bootstrap()-在不需要ng应用程序或ng控制器的情况下引导angular应用程序
- 页面上未显示多个ng应用程序
- 将多个ng应用组合成一个应用
- 多个ng应用程序问题
- Angular.js ng应用程序不仅可用于控制器
- ng应用程序的输出