简体   繁体   English

在多个oi.select angularjs中获得单击选项

[英]Get clicked option in multiple oi.select angularjs

    <oi-select class="oi-select" 
        oi-options="student.name for student in students track by student._id" 
        multiple placeholder="" ng-model="class.students" ng-change="clickedName()">
    </oi-select>

This is multiple select options. 这是多个选择选项。 I want to know the clicked option of the oi.select; 我想知道oi.select的clicked选项; both selected and deselected. 选中和取消选中。 How to write this in angular way? 如何用角度的方式写这个? Thanks. 谢谢。

You can get the clicked option by accessing the ng-model, 您可以通过访问ng-model来获得clicked选项,

<oi-select class="oi-select" 
        oi-options="student.name for student in students track by student._id" 
        multiple placeholder="" ng-model="student" ng-change="clickedName()">
 </oi-select>

Controller:

console.log($scope.student);

Or you can pass the selected one via ng-change, 或者,您可以通过ng-change传递所选的内容,

 <oi-select class="oi-select" 
            oi-options="student.name for student in students track by student._id" 
            multiple placeholder="" ng-model="student" ng-change="clickedName(student)">
 </oi-select>

Controller

$scope.clickedName = function(selected){
 console.log(selected.name);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM