<div ng-show ="formMode == 'HotelSearch'" id="hotelResults" ng-controller="hotelSearchCtrl">
<div class="row" ng-repeat="hotel in hotels">
<div class="col-md-6 col-lg-4 col-sm-12">
<div class="card">
<div class="front">
<div class="cover">
<img src="images/city.jpg" class="img-responsive"/>
</div>
<div class="content">
<div class="main">
<h3 class="name">{{hotel.name}}</h3>
<h5><i class="fa fa-map-marker fa-fw text-muted"></i> {{hotel.location}}</h5>
<h5><i class="fa fa-building-o fa-fw text-muted"></i> {{hotel.phone}}</h5>
<h5><i class="fa fa-envelope-o fa-fw text-muted"></i> {{hotel.email}}</h5>
</div>
<div class="footer">
</div>
</div>
</div> <!-- end front panel -->
</div>
<!-- end card -->
</div>
</div>
</div>
Above is the code for my angular view. It is meant to show the results of a search i perform. I know i am getting my results back because i am logging it, but my view is not displaying these results.i'm new to angular and using this to learn, so i'm not really sure what the issue is.
app.controller('hotelSearchCtrl',['$scope','$http',
function ($scope,$http)
{
$scope.hotels = {};
$scope.hotelSearch = function ()
{
$http.post('/getonehotel',
{
name:$scope.hotelName
}).
then(
function onSuccess(response)
{
$scope.hotels = response.data;
console.log($scope.hotels);
}).
catch(
function onError(err)
{
toastr.error('An error has occured, please try again later', 'Error', { closeButton: true});
console.log(err);
});
}
}
]);
Above is the code for my controller.i first used a get request to try and get the data, but since i'm passing a search parameter the get request wasn't working for me.so i'm using a post to post the parameter and get back the response. I am using the sails framework.
I have 2 different radio buttons to show different divs depending on which radio is selected. I know this works because the code below renders the way it should.
<div class="container" id="results">
<div ng-show ="formMode == 'HotelSearch'" id="hotelResults" ng-controller="hotelSearchCtrl">
<h2>hotels</h2>
</div>
<div ng-show ="formMode == 'FlightSearch'" id="flightResults">
<h2>Flight</h2>
</div>
</div>