避免使用ng-option

时间:2015-10-12 07:48:23

标签: javascript angularjs

我对AngularJS很新。我的模型如下: -

class Role {
  String id;
  String role_name;
  Role parentid;  // Parent of role
}

我希望避免使用循环链接,因为NewRole1是其自身的父级和子级,并且只有那些将启用和保留的parentid == null的角色将处于禁用状态。

我已经编写了下面的代码,但它无法正常工作。

<input type="text" class="form-control" name="role_name" id="field_role_name" 
       ng-model="role.role_name" ng-model="testname" 
       required ng-maxlength="45">

<select class="form-control" id="field_role_r_name" name="role_r_name" 
       ng-model="role.parentid"
       ng-options="role1 as role1.role_name disable when (role1.role_name==role.role_name || role1.parentid.id!=null) for role1 in roles track by role1.id">
   <option value=""></option>
</select> 

它阻止NewRole1成为其自身的父级,但是当条件无法正常工作时我的role1.parentid.id!=null。我想禁用所有有瘫痪的角色。 有人可以指导我上面有什么不妥。

0 个答案:

没有答案