Ich bin nicht in der Lage, ausgewählter Wert zurück zum Modell, aber in der Lage, Modellwert als ausgewähltes Element im ausgewählten Steuerelement zu binden.Get ausgewählten Optionswert Winkel js Modell
Ausblick:
<div data-ng-repeat="BI in BulkInvoice">
<select class="input-sm form-control input-s-sm inline" ng-disabled="!edit" data-ng-model="BI.DefaultCostType">
<option value="">Select</option>
<option ng-selected="BI.DefaultCostType == item.ID"
ng-repeat="item in costTypes"
ng-value="item.ID">
{{item.Name}}
</option>
</select>
</div>
Controller:
$scope.BulkInvoice = [{
DefaultCostType : 4
}];
obigen Code verwenden, wählen Sie Steuerung ist in der Lage ausgewähltes Element zu setzen, basierend auf ID in BulkInvoice. Wenn der Benutzer die Option zum Speichern ändert, wird die geänderte Option nicht zurück an das Modell gesendet. Bitte helfen.
Output html:
<select class="input-sm form-control input-s-sm inline" ng-disabled="!edit">
<option value="">Select</option>
<!-- ngRepeat: item in costTypes --><option ng-selected="BI.DefaultCostType == item.ID" ng-repeat="item in costTypes" ng-value="item.ID" ng-model="BI.DefaultCostType" class="ng-pristine ng-untouched ng-valid ng-binding ng-scope ng-not-empty" value="1">
Claim Cost
</option><!-- end ngRepeat: item in costTypes --><option ng-selected="BI.DefaultCostType == item.ID" ng-repeat="item in costTypes" ng-value="item.ID" ng-model="BI.DefaultCostType" class="ng-pristine ng-untouched ng-valid ng-binding ng-scope ng-not-empty" value="3">
Expense - A&O
</option><!-- end ngRepeat: item in costTypes --><option ng-selected="BI.DefaultCostType == item.ID" ng-repeat="item in costTypes" ng-value="item.ID" ng-model="BI.DefaultCostType" class="ng-pristine ng-untouched ng-valid ng-binding ng-scope ng-not-empty" value="4">
Expense - D&CC
</option><!-- end ngRepeat: item in costTypes --><option ng-selected="BI.DefaultCostType == item.ID" ng-repeat="item in costTypes" ng-value="item.ID" ng-model="BI.DefaultCostType" class="ng-pristine ng-untouched ng-valid ng-binding ng-scope ng-not-empty" value="2" selected="selected">
Unspecified Cost Type
</option><!-- end ngRepeat: item in costTypes -->
</select>
Können Sie den generierten HTML zeigen? – puelo
hinzugefügt Ausgabe html –