我正在尝试将 DOM 元素的模型设置为给定特定属性的特定子对象。在此特定示例中,“Employees”对象的结构如下:
var Employees = [
{EmployeeID:1000
Name: Jimmy
ManagerID: null}
{EmployeeID:1001
Name: James
ManagerID: 1000}
{EmployeeID:1002
Name: Steve
ManagerID: 1000}
]
我希望使用过滤器的内联 Curley Brace 指令能够帮助我解决它。接下来的内容显然不起作用,但希望它证明了我想要它做的事情。
<div ng-repeat="Emp in Employees">
<span>Employee #:{{Emp.EmployeeID}}</span>
<img src="../../Content/images/Photos/{{Emp.EmployeeID}}.jpg"/>
<h4>{{Emp.Name}}</h4>
<h5>Manager:</h5>
<!--The following is what I do not know how to do-->
<span>{{Employees.Name | filter:Employees.EmployeeID = Emp.EmployeeID }}</span>
</div>
最终结果是:
Employee #:1000
<img>
Jimmy
Manager:
<!--I'll figure out what to do with null values in a bit. first things first-->
Employee #:1001
<img>
James
Manager:
Jimmy
Employee #:1002
<img>
Steve
Manager:
Jimmy