I want to show a status whether the shop is open or close based on current time. So here is the code.
In controller
$http.get(httpUrl + 'shops/get_shops')
.then(function (returns) {
$scope.shops = returns.data;
});
var now = new Date();
$scope.current_time = now.getHours() + ':' + now.getMinutes() + ':00';// to get hh:mm:ss format
In the view
<div ng-repeat="item in shops">
<span ng-if="item.open_hour != '00:00:00' && item.open_hour <= '{{current_time}}' && item.close_hour >= {{current_time}}">We're open</span>
</div>
The problem is that the result is only meet the first condition item.open_hour != '00:00:00' and the rest are disobeyed. So all the data which have open_hour not '00:00:00' will be open regardless the open_hour and close_hour.
I'm new to angularjs and don't know how to do thing like this. Please any help will be appreciated.
<span ng-if="{{item.open_hour != '00:00:00' && item.open_hour <= 'current_time' && item.close_hour >= current_time}}">We're open</span>change to thisitem.open_hour <= 'current_time'→ current_time it's a scope var not a string.