2013-10-25 32 views
21

我有,我想,如果用户从选择框中选择一个特定的值设置为禁用输入按钮:angularjs NG-禁用禁用不添加到按钮

选择菜单:

<select id="jobstatus" name="jobstatus" ng-model="associate.JobStatus" class="form-control"> 
     <option value="0">Current</option> 
     <option value="1">Former</option> 
     <option value="2">Never worked there</option> 
</select> 

输入按钮:

<input type="submit" class="btn btn-info pull-right 
btn-lg btn-block" ng-disabled="{{associate.JobStatus === '2'}}" /> 

现在,当我查看源代码,当我做选择的选项2,从价值ng-disabled="false"输入按钮元素更改为ng-disabled="true"但禁用的属性不应用于按钮。

我在这里做错了什么?

回答

23

角文件ngDisabled

大括号表示符号{{}}来表达结合元件是内置的角标记。

用途:

<input type="submit" ng-disabled="associate.JobStatus == 2" /> 

相反的:

<input type="submit" ng-disabled="{{associate.JobStatus == 2}}" /> 

相同NG-显示/ NG隐藏/ NG-如果,您可以使用模型 表达式本身而不是{{}}

例如: -

用途:

<div ng-show="someObject.showProperty"> 

相反的:

<div ng-show="{{someObject.showProperty}}">