简体   繁体   English

AngularJs-禁用ng

[英]AngularJs - ng-disabled

I have following two input fields. 我有以下两个输入字段。 The only difference is ng-disabled directive. 唯一的区别是ng-disabled指令。

So, there is repetition of code.I am looking forward to use only one input tag for by fulfilling both purposes. 因此,有重复的代码。我期待通过实现这两个目的而仅使用一个input标签。

How i can combine these two inputs with showing/hiding ng-disabled directive based on condition? 如何根据条件将这两个输入与显示/隐藏ng-disabled指令结合使用?

<input type="radio" name="student_role" ng-model="student.RoleId" />

<input type="radio" name="role" ng-disabled="loggedStudent == student.Student.Email" ng-model="student.RoleId"  />

你试一试

<input type="radio" name="role" ng-disabled="(loggedStudent == student.Student.Email) ? true : false" ng-model="student.RoleId"  />

这应该工作:

    <input type="radio" name="role" ng-if="loggedStudent == student.Student.Email" ng-model="student.RoleId"  />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM