1. 程式人生 > >angular select ng-change實時獲取value

angular select ng-change實時獲取value

<select ng-model="vm.selectVal" ng-options="o.id as o.title for o in vm.optionsData" ng-change="selectChange()">
    <option value="">請選擇</option>
</select>
vm.optionsData = [{
    id : 4543,
    title : "angularJs"
},{
    id : 546,
    title : "emberJs"
},{
    id : 456,
    title : 
"backboneJs" },{ id : 75, title : "knockoutJs" }]; $scope.selectChange = function(){ //添加了ng-change事件來試試id值的輸出 console.log(vm.selectVal); }

原文:https://www.cnblogs.com/leejersey/p/4663949.html