我正在检查控制器中的值。这是我的代码。如何在angularjs中检查字符串是否为空
var contents = atob(response.documents);
// I checked the value in contents . it is displaying ""
if(contents === ""){
// no contents
}
if条件是重新调用false,当内容有“”和内容有数据时。 如何检查条件?
我正在检查控制器中的值。这是我的代码。如何在angularjs中检查字符串是否为空
var contents = atob(response.documents);
// I checked the value in contents . it is displaying ""
if(contents === ""){
// no contents
}
if条件是重新调用false,当内容有“”和内容有数据时。 如何检查条件?
好的平原的Javascript。
if(!contents){
}
空字符串falsey你可以使用:
if(contents){
//has content
}else{
//no content
}
在javascript中 “” 是假的,当你比较一下 “”,它总是给人真正。也许你已将空字符串(空字符串内部的空字符串)加倍
[AngularJS-ng-if检查字符串空值]的可能重复(http://stackoverflow.com/questions/27380000/angularjs-ng-if-check-string-空值) –