Select One option and onChange event will read the data and display the same inside a div.
After selection details will appear here
<div ng-app="my_app" ng-controller="my_ctrl">
<select ng-model="students" ng-options="x.name for x in details" ng-change="onChange()" >
</select>
</div>
<br><br>
<div class='alert alert-primary' role='alert' id=d1>After selection details will appear here</div>
<script>
var app = angular.module('my_app', []);
app.controller('my_ctrl', function($scope, $http) {
$http.get("student-data.php") // data source for options
.then(function (response) {$scope.details = response.data.student_data;});
$scope.onChange = function()
{
var id=$scope.students.id;
var name=$scope.students.name;
document.getElementById('d1').innerHTML="Welcome " + name + " Your id : " + id;
}
});
</script>
← Dropdown List Box DEMO: onChange Event to post selected option to back end script→
←DEMO: Options using JSON format ←DEMO: Options from MySQL database
← Displaying records from MySQL database table