select * from cijfer where naam=naam

select * from cijfer where naam=:naam

嗨,这是我的代码的一部分我试图调用一个函数并传递所选选项(记录)的id,但它没有调用该函数。我也尝试过ng-click。我错过了什么?提前谢谢。
答案 0 :(得分:0)
您需要 <select>
而不是数据列表,还要使用 ng-model
变量
<强> DEMO
强>
var app = angular.module('testApp',[]);
app.controller('testCtrl',function($scope){
$scope.empobj=[{first_name:"new",last_name:"sjkk",id:"2"},{first_name:"new",last_name:"sjkk",id:"3"},{first_name:"new",last_name:"sjkk",id:"4"}];
$scope.selectedemp1= function(id){
console.log(id);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="testApp" ng-controller="testCtrl">
<input type="text" class="form-control" id="inputemployee" ng-model="empname" list="suggestions" >
<select ng-options="emp as emp.last_name for emp in empobj"
ng-model="selected" ng-change="selectedemp1(selected.id)"></select>
</body>