2

我正在为 select2 使用角度 ng-model 进行数据绑定。{{数字.文本}}

<select id="e2" ui-select2 ng-model="select2.text" data-placeholder="Pick a number">
    <option value=""></option>
    <option ng-repeat="number in range" value="{{number.text}}">{{number.text}}</option>
</select>
</div>

我在这里面临两个问题:1)ng-change 似乎不起作用,因此我不得不使用 document.getElementByID.. 2)select2.text 的值在这里没有得到更新

function sampleController($scope,$timeout){
$scope.select2={text:"",id:""};
$scope.range=[{text:"name1", value:"id1"},
    {text:"namea2", value:"id2"},
    {text:"name3", value:"id3"}];

$timeout(function(){
    $("#e1").select2();},10
)
document.getElementById("e1").onchange = function(){
    $scope.select2.id = "selected";
}
}
4

0 回答 0