I have a small app in Angular.js. I have a page where it gets input from the user about the room booking and stores in database and loads the same data when needed.
I use Angular select option to load rooms list. It lists the rooms fine, and when I store the selected room it's storing fine. But when I want to display the same room in select list, it's not working.
Here is my code:
<script>
var app = angular.module('myApp', []);
app.controller('bookingcontroller',function($scope,$http){
$http.get("../pages/php/getrooms.php")
.then(function (response) {$scope.rooms = response.data;});
$scope.insertbooking = function(){
$http.post("../pages/php/booking.php", {
'bookingno' : $scope.bookingno,
'bookingdate' : $scope.bookingdate,
'roomsno' : $scope.rooms.RoomSno
})
.success(function(data,status,headers,config){
alert ("success");
});
}
$scope.loadbooking = function(so){
$http.get("../pages/php/getbookings.php?loadsno=" + so.booksno)
.then(function (response)
{
$scope.bookingno = response.data[0].bookingno;
$scope.bookingdate = response.data[0].bookingdate;
$scope.roomname.RoomSno = response.data[0].RoomSno;
$scope.roomname.Room_Name = response.data[0].Room_Name;
}
});
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtl">
<select ng-model="roomname" ng-options="r.Room_Name for r in rooms">
</select>
</div>
</body>