AngularJS null value for select

后端 未结 9 918
攒了一身酷
攒了一身酷 2021-02-01 14:32

I couldn\'t find an elegant way for setting null values with a

9条回答
  •  遥遥无期
    2021-02-01 14:59

    the only way you can achieve that is by using a onchange event and restoring the object as initialized any other attempt to set the selected to null will remove the property from the object.

    $scope.setValue=function(val){
      if($scope.obj.selected=="null")
         $scope.obj ={"selected":null};
    }
    
    
    

    this is a bad idea, you should always have values in your model instead of playing around with null and undefined

提交回复
热议问题