Check if value is not empty and not null in angular template?
问题 How do I check if value is not empty and not null. in Controller: $scope.data.variable = 'some valid data'; <div ng-if="data.variable != ''">something else</div> Thanks 回答1: since both null and empty are falsy values div.variable if not null or empty will evaluate to true and if either of null or empty will evaluate to false <div ng-if="data.variable">something else</div> 回答2: I suggest you have such a function is your controller: $scope.isEmpty = function(value){ return (value == "" || value