我有2个选择。
一为Leagues
一为Divisions
我想创建一个Pipe
将Divisions
根据League
所选内容进行过滤的。
下面给出数据。如果我Random Beer League
只选择TwoFour
并且SixPack
应该显示为选择的Divisions
选项。
leagues = [
{id: 1, leagueName: 'Recreation League' },
{id: 2, leagueName: 'Random Beer League' }
];
divisions = [
{id: 1, divisionName: 'SoGreen', leagueId: 1, leagueName: 'Recreation League' },
{id: 2, divisionName: 'Yellow', leagueId: 1, leagueName: 'Recreation League' },
{id: 3, divisionName: 'TwoFour', leagueId: 2, leagueName: 'Random Beer League' },
{id: 4, divisionName: 'SixPack', leagueId: 2, leagueName: 'Random Beer League' }
];
*注意 - plunker 中的数据是硬编码的,但在我的应用程序设置中它的 Observable。