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

时间:2016-11-25 01:57:01

标签: javascript angularjs drop-down-menu

    <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>

这是多个选择选项。我想知道oi.select的点击选项;选择和取消选择。如何以角度方式写这个?感谢。

1 个答案:

答案 0 :(得分:0)

您可以通过访问ng-model

来获取单击的选项
<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);

或者您可以通过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);
}