我 NG-重复
选项:
<选项NG重复=今年data.dateList.yearVALUE ={{year.id}}NG-禁用=(year.id< 2015年)真?假>
您可以看到 NG-禁用=(year.id< 2015年)真的?假的
为什么我的选项没有被禁用,如果 year.id
低于2015年?
这是我的新code:
< DIV CLASS =ITMNG重复=一个范围内(NUM)由$指数跟踪> <选项NG重复=今年data.dateList.yearNG-禁用=(year.id)LT; formData.beginYear [$指数]> {{year.value}} < /选项>< / DIV>
![IE浏览器怎样禁用js javascript](/d/file/2023/09-17/012f51565523d68d55ecf3b1ea8abd7d.png)
解决方案
您需要在这里用NG选项有办法禁用选项
<选择NG模型=年 NG-选项=year.id禁用时(year.id< 2015年),为今年data.dateList.year>< /选择>
更新
有关两个输入场依赖对方,你可以像下面。主要的问题是当你在做比较,这是字符串,如值
属性值转换为字符串
格式。你可以使用 NG-选项
,做preserves值和放大器的的dataType
;将同时使更多的比较容易。
标记
<选择NG模型=年[$指数] NG-选项=year.id在几年year.id的一年>< /选择><选择NG模型=年 NG-选项=year.id禁用时(year.id<年[$指数])为一年年>< /选择>
演示Plunkr
I have ng-repeat
option:
<option ng-repeat="year in data.dateList.year" value="{{year.id}}" ng-disabled="(year.id < 2015) ? true : false">
You can see ng-disabled="(year.id < 2015) ? true : false"
Why my option is not disabled if year.id
less than 2015?
This is my new code:
<div class="itm" ng-repeat="a in range(num) track by $index">
<option ng-repeat="year in data.dateList.year" ng-disabled="(year.id) < formData.beginYear[$index]">
{{year.value}}
</option>
</div>
解决方案
You need to use ng-options here which has way to disable the options
<select ng-model="year"
ng-options="year.id disable when (year.id < 2015) for year in data.dateList.year">
</select>
Update
For two input field depends each other, you can do it like below. Main problem was while you were doing comparison it was string, as value
attributes convert the value to string
format. You could use ng-options
that does preserves the dataType
of the value & will make more easier while making comparison.
Markup
<select ng-model="yr[$index]"
ng-options="year.id as year.id for year in years">
</select>
<select ng-model="year"
ng-options="year.id disable when (year.id < yr[$index]) for year in years">
</select>
Demo Plunkr
相关推荐
最新文章