我想选择已存储的“id”并在表单中显示,我需要编辑表单,我需要启动表单,选择存储时使用各自名称保存的id。< / p>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html, body, iframe {
width: 100%;
height: 100%;
}
@media (max-device-width: 740px) {
.desktop-iframe { display: none; }
}
@media (min-device-width: 741px) {
.iphone-iframe { display: none; }
}
</style>
</head>
<body>
<iframe class='iphone-iframe' scrolling='no' src='https://en.wikivoyage.org/wiki/S%C3%A3o_Paulo/Northeast'></iframe>
<iframe class='desktop-iframe' src='https://en.wikivoyage.org/wiki/S%C3%A3o_Paulo/Northeast'></iframe>
</body>
</html>
“dataOrder.operative_order_id”和“orderoperatives.id”具有相同的值,我想要的是显示该值的名称。
如果dataOrder.operative_order_id = 2我需要在ng-option中“选中”
<select class="form-control"
ng-model="vm.operative_order_id"
ng-selected="dataOrder.operative_order_id" <!--The "id" or "operative_order_id" is from a related table -->
ng-options="orderoperatives.id as orderoperatives.nombre for orderoperatives in dataOperatives"></select>
答案 0 :(得分:2)
<select class="form-control"
ng-model="vm.operative_order_id" >
<option ng-repeat = "item in orderoperatives " value = "{{item .id}}">{{item .nombre}}}</option>
</select>
你能尝试这样:)
答案 1 :(得分:1)
您不需要ng-selected
试试这个
<select class="form-control" ng-model="dataOrder.operative_order_id"
ng-options="orderoperatives.id as orderoperatives.nombre for
orderoperatives in dataOperatives"></select>
或试试这个
<select class="form-control"
ng-model="vm.operative_order_id"
ng-selected="dataOrder.operative_order_id" ng-options="orderoperatives.id as orderoperatives.nombre for orderoperatives in dataOperatives"></select>
您应该在控制器中将dataOrder.operative_order_id
分配给vm.operative_order_id
,例如
$scope.operative_order_id=$scope.dataOrder.operative_order_id;