AngularJS null value for select

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

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

9条回答
  •  长情又很酷
    2021-02-01 15:02

    This should work for you:

    Controller:

      function MyCntrl($scope) {
        $scope.obj ={"selected":null};
        $scope.objects = [{id: 1, value: "Yes"}, {id: 0, value: "No"}]
      }
    

    Template:

      

    {{obj}}

    Working plnkr

    You should use ng-options with select.

提交回复
热议问题