angularjs警报消息不正确

时间:2017-12-20 14:17:47

标签: angularjs model-view-controller asp.net-mvc-5 angularjs-scope

当没有选择下拉列表时,消息会出现但是当选择任何一个或多个下拉列表时,消息即将来临请选择至少一个.Below is my angularjs

$scope.check = function () {


 if ($scope.landing.class == null || $scope.landing.class == undefined|| $scope.landing.class == "" && $scope.landing.fueltype == undefined || $scope.landing.fueltype == null || $scope.landing.fueltype == "" && $scope.landing.transmiss == null || $scope.landing.transmiss == undefined || $scope.transmiss == "" && $scope.landing.driving == null || $scope.landing.driving == undefined || $scope.driving == "" && $scope.landing.pick == null || $scope.landing.pick == undefined || $scope.landing.pick == "" && $scope.landing.stat == null || $scope.landing.stat == undefined || $scope.landing.stat == "") {
            alert('Please select atleast one')
        }
    }

1 个答案:

答案 0 :(得分:1)

您可能需要额外的括号......

if (($scope.landing.class == null || $scope.landing.class == undefined || $scope.landing.class == "" )
&& (
$scope.landing.fueltype == undefined || $scope.landing.fueltype == null || $scope.landing.fueltype == "" )
&& (....

但总的来说这很难看,你必须找到一种更好/更聪明的方法来进行验证。