我有一个过滤器,因此您可以过滤角色。它看起来像这样:
<h3>Role</h3>
<form>
<div class="radio radio-primary">
<label>
<input checked="checked" ng-click="homeCtrl.roleFilter = ''" name="role" type="radio"/><span class="circle"></span><span class="check"></span>Alles
</label>
</div>
<div class="radio radio-primary" ng-repeat="employee in homeCtrl.employees | unique:'Role.RoleName'">
<label>
<input ng-click="homeCtrl.roleFilter = employee.Role.RoleName" name="role" type="radio"/><span class="circle"></span><span class="check"></span>{{ employee.Role.RoleName }}
</label>
</div>
</form>
<table class="table table-hover">
<thead>
<tr>
<th>Functie</th>
<th>Bedrijf</th>
<th>Naam</th>
<th>Achternaam</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in homeCtrl.employees | filter: { Role.RoleName: homeCtrl.roleFilter }" ng-click="homeCtrl.redirectToShow(employee.EmployeeId,$event)">
<td>{{ employee.Role.RoleName }}</td>
<td>{{ employee.Department.Company.CompanyName }}</td>
<td>{{ employee.FirstName }}</td>
<td>{{ employee.LastName }}</td>
<td ng-if="homeCtrl.canEditAdmin || homeCtrl.canEditInternAdmin && employee.Role.RoleName == 'Stagiaire'" ng-click="homeCtrl.redirectToEdit(employee.EmployeeId,$event)"><span class="glyphicon glyphicon-pencil"></span></td>
</tr>
</tbody>
</table>
但它没有用。当我在控制器中console.log
时,一切都是正确的。可能有什么不对?
错误讯息:
Error: $parse:syntax
Syntax Error
Syntax Error: Token '.' is unexpected, expecting [:] at column 36 of the expression [homeCtrl.employees |] starting at [{4}].
当我将RoleName
直接放在员工对象上时:employee.RoleName
(而不是employee.Role.RoleName
)它正在运作?!
- 编辑 -
答案 0 :(得分:2)
我的评论中发布的解决方案:
filter: { Role:{RoleName: homeCtrl.roleFilter }}