我正在尝试创建一个显示客户列表的视图,因为它是一个对象而且是因为Ionic的html类型,所以我遇到了问题。
这是我的目标:
longest_line
我将longest_line = ...
largest_H = 0; % init value
for n=1:12
binary_image = edge(input_images{n},'canny');
[H,T,R] = hough(binary_image);
P = houghpeaks(H,1,'threshold',ceil(0.3*max(H(:))));
hough_lines = houghlines(binary_image,T,R,P,'FillGap',500,'MinLength',7);
if (largest_H < H(P(1, 1), P(1, 2)))
largest_H = H(P(1, 1), P(1, 2));
longest_line = hough_lines(1);
longest_line.image = n;
end
end
定义为x = { Consultation: [{name: "Joe Smith}, {name: "Jane Doe"}],
Re-evaluation: [{name: "Joe Smith2}, {name: "Jane Doe2"}],
Meeting: [{name: "Joe Smith3}, {name: "Jane Doe3"}],
Testing: [{name: "Joe Smith4}, {name: "Jane Doe4"}]
}
又名appointment_types
。
在我看来:
Object.keys(x)
我可以做些什么来留在["Consultation", "Re-evaluation", "Meeting", "Testing"]
循环中吗?
答案 0 :(得分:5)
您可以通过在ion-list
中进行类型的迭代来解决此问题:
<ion-list *ngFor="let type of appointment_types">
然后当你拥有type
和原始对象x
时,可以使用内部数组迭代x
对象,如:
<ion-item-sliding class="shaded-slider" *ngFor="let client of x[type]">
所以你的完整模板看起来像这样:
<ion-list *ngFor="let type of appointment_types">
<ion-list-header >{{ type }}</ion-list-header>
<ion-item-sliding class="shaded-slider" *ngFor="let client of x[type]">
<ion-item>{{ client.name }}</ion-item>
</ion-item-sliding>
</ion-list>
这是 PLUNKER