在角度4中,如何在选择选项中获取所选值的id?

时间:2018-02-14 13:57:21

标签: angular

通过使用TransactionDto resultAlias = null; var results = session.QueryOver<TransactionTable>(() => transactionAlias) .Left.JoinAlias(pr => pr.UserFrom, () => usersFromAlias) .Left.JoinAlias(pr => pr.UserTo, () => usersToAlias) .Left.JoinAlias(pr => pr.GatewayTable, () => gatewayAlias) .SelectList(list => list .Select(pr => pr.TransactionId).WithAlias(() => resultAlias.TransactionId) .Select(pr => pr.Amount).WithAlias(() => resultAlias.Amount) .Select(pr => pr.Reason).WithAlias(() => resultAlias.Reason) .Select(pr => pr.TransactionDatetime).WithAlias(() => resultAlias.TransactionDatetime) .Select(pr => pr.GatewayTableId).WithAlias(() => resultAlias.GatewayTableId) .Select(Projections.Conditional( Restrictions.Eq( Projections.Property(() => transactionAlias.UserFromId), 0), Projections.Constant("Paypal"), Projections.Property(() => usersFromAlias.FullName) )).WithAlias(() => resultAlias.UserFromName) .Select(Projections.Conditional( Restrictions.Eq( Projections.Property(() => transactionAlias.UserToId), 0), Projections.Constant("Paypal"), Projections.Property(() => usersToAlias.FullName) )).WithAlias(() => resultAlias.UserToName)) .TransformUsing(Transformers.AliasToBean<TransactionDto>()) .List<TransactionDto>(); ,我们可以获得它,但下拉列表中不会显示默认值。我们还有其他选项可以访问所选值吗?

我的更多代码如下:

[(ngModel)]="topic.id"

1 个答案:

答案 0 :(得分:0)

我不确定你要求的是什么,但我相信你希望能够获得所选项目的ID?我附上了一个快速实现的stackblitz,它将演示如何做到这一点。如果这不完全是你想要完成的事情,请告诉我。

https://stackblitz.com/edit/angular-dnwcf6