我有这样的条件
<table ng-if="name=='john' && name=='MARK'">
//rest of the code
</table>
Run Code Online (Sandbox Code Playgroud)
当ng-if为true时,我的代码将执行.
现在我的疑问是,即使名字是大写和小写,ng-if也应该是真的.
<table ng-if="name=='JOhN' && name=='maRK'">
//rest of the code
</table>
Run Code Online (Sandbox Code Playgroud)
可能吗?我也试过这个if-else条件.
if(name.toString()='john'){
alert('success')
}
else{
alert('failure')
}
Run Code Online (Sandbox Code Playgroud)
这是对的吗?
这是我的代码
<div class="EquipmentContent row">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 subSection" style="float:right;background:#dff0ff;">
<section class="col-xs-12 col-sm-1 cl-md-1 col-lg-1">
<button type="button" style="display: inline-block;float:right;" class="btn btn-danger" onclick="hideEquipmentDetails()"><i class="fa fa-times"></i></button>
</section>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这里是动态加载div数据
var content= response.data.filters;
$.each(content,function(i,value){
$('.subSection').html('<section class="col-xs-12 col-sm-2 cl-md-2 col-lg-2"><label class="equipmentHeaderlable">Name</label><label class="equipmentHeaderValues">'+value.name+'</label></section>').appendTo('.EquipmentContent');
});
Run Code Online (Sandbox Code Playgroud)
它正确循环但只显示第一个对象.(即我在一个数组中有6个名字,但它只显示第一个名字.)为什么呢?我试过添加滚动和高度.
还有一件事我怎样才能动态地附加这一部分?
<section class="col-xs-12 col-sm-1 cl-md-1 col-lg-1">
<button type="button" style="display: inline-block;float:right;" class="btn btn-danger" onclick="hideEquipmentDetails()"><i class="fa fa-times"></i></button>
</section>
Run Code Online (Sandbox Code Playgroud) 我正在制作传单地图和标记。
我从 JSON 获取标记 latlng 并正确显示。
getLatLng()
function getLatLng() {
var details = '/equipment/api/getLatLong';
$.ajax({
url: details,
method: 'get'
}).done(function(response) {
$('.subSection').html('').append('<section><button type="button" onclick="hideEquipmentDetails()"><i class="fa fa-times"></i></button></section>');
var equipmentDetails = response.data.filters;
console.log(equipmentDetails)
$.each(equipmentDetails, function(i, value) {
L.marker([value.latitude, value.longitude]).addTo(map).bindPopup('<b><span> Name:</span>' + value.name + '</b>');
})
});
}
setInterval(function() {
getLatLng();
}, 5000)
Run Code Online (Sandbox Code Playgroud)
我每 5 秒刷新一次方法。
所以我需要在更新的 latlng 中显示标记,并且应该隐藏旧标记。
setInterval(function() {
//L.marker.setOpacity(0);
//L.markerClusterGroup()
//markers.clearLayers();
//map.removeLayer(L.marker);
//markers.removeLayer()
//L.marker().removeTo(map);
getLatLng();
}, 5000)
Run Code Online (Sandbox Code Playgroud)
我尝试了所有选项来实现这一目标,但我做不到。
有没有其他方法可以做到?
否则我应该再定义一个数组来存储初始 latlng 值,然后每次检查 latlng 是否更改(在这种情况下,我只能替换更新的 latlng 标记,对吗?不需要每次都替换所有标记,对吗?)