大家好,我是 Angular 和 js 的新手,我正在学习 ng-show。 我发现如果 Controller 中的条件无法对值进行切片或子字符串化
我的代码是
<tbody>
<tr>
<td>
<input type="text" ng-model="row1" size=6/ disabled>
</td>
<td>
<input type="text" ng-model="dup_row1 " size=6/>
</td>
</tr>
<tr ng-show="row2()">
<td>
<input type="text" ng-model="dup_row1" size=6/>
</td>
<td>
<input type="text" ng-model="dup_row2 " size=6/>
</td>
</tr>
</tbody>
Controller 包含
$scope.row2=function(){
if($scope.dup_row1.substr(0,2) > 24){
return true;
}
}
我只想检查前两个数字以显示下一行
如有任何建议,请提供链接 http://jsfiddle.net/u3yj39u9/
提前致谢
最佳答案
始终遵循始终使用“.”的“最佳实践”在你的 ng-models 中,你避免了很多问题。
在你的 Controller 上也是如此:
$scope.tableVals = {};
然后你所有的值都应该是这个对象的属性。
This article可能会有帮助。
这里你有一个工作 example
关于javascript - Angular if 条件不读取 ng-show 的 substr 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32169363/