Ich habe einen DropDown. Ich verbinde es Wert mit ng-repeat
auf Option. Ich möchte den ausgewählten Wert nur über das Wertfeld festlegen.Kann den ausgewählten Wert von DropDown nicht einstellen In angularJs
Dies ist mein Code.
<div ng-controller="myCtrl">
<select ng-model="selectedItemvalue">
<option value="">--Select --</option>
<option ng-repeat="sel in selectables" value="{{sel.value}}">{{sel.label}}</option>
</select>
<p>Selected Value is : {{selectedItemvalue}}</p>
</div>
Js
angular.module('myApp', [])
// controller here
.controller('myCtrl', function($scope) {
$scope.selectables = [
{ label: 'A', value: 1},
{ label:'B', value: 2},
{ label: 'C', value: 3}
];
// this is the model that's used for the data binding in the select directive
// the default selected item
//using value, i want to set the selected value
$scope.selectedItemvalue = "2";
})
Wie Sie sehen können, möchte ich uisng nur ausgewählte Wert einstellen Wert Durch die Einstellung.
Siehe den aktualisierten Link. Immer noch das gleiche Problem –
@AmitKumar sehen Sie die Demo in der aktualisierten Antwort :) –
Aber Intially, zweite Itme ist nicht in Ihrer Demo ausgewählt, –