Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在angular js中使用if条件语句_Javascript_Angularjs_If Statement_Time - Fatal编程技术网

Javascript 如何在angular js中使用if条件语句

Javascript 如何在angular js中使用if条件语句,javascript,angularjs,if-statement,time,Javascript,Angularjs,If Statement,Time,我想根据当前时间显示店铺是开门还是关门的状态。这是代码 内部控制器 $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 for

我想根据当前时间显示店铺是开门还是关门的状态。这是代码

内部控制器

$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
在视图中

<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>

我们开门
问题是结果仅满足第一个条件
item.open\u hour!='00:00:00'
其他人都不服从。因此,所有打开时间不是“00:00:00”的数据都将打开,无论打开时间和关闭时间如何


我是angularjs的新手,不知道怎么做这样的事情。如果您有任何帮助,我们将不胜感激

当您在
ng if
中时,您不需要
{{}
来获取范围变量

<span ng-if="item.open_hour != '00:00:00' && item.open_hour <= current_time && item.close_hour >= current_time">We're open</span>
我们开门了

我们已打开
更改为this@HardikVaghani你的答案是错的<代码>item.open_hour@HardikVaghani这就是工作!!但我认为在目前的情况下应该没有报价。无论如何谢谢你