How to make a radio ion required, or make the button idle until you do not choose an option?

0

How can I make a radio ion as required, or disable the button if nothing is selected?

  <ion-radio ng-model="escolhido.categoria_comida_cod_categoria_com" ng-value="'{{item.categoria_comida_cod_categoria_com}}'" ng-required="true">{{item.categoria_comida_nome}}</ion-radio>

Follow the button:

 <ion-list ng-repeat="item in categoriass | filter:q as results" ng-init="$last ? fireEvent() : null">

            <ion-radio ng-model="escolhido.categoria_comida_cod_categoria_com" ng-value="'{{item.categoria_comida_cod_categoria_com}}'" ng-required="true">{{item.categoria_comida_nome}}</ion-radio>
        </ion-list>


        <div class="spacer" style="width: 300px; height: 40px;"></div>

        <button class="button button-full button-assertive" ng-click="SelecionaCategoria(escolhido)">
            Continuar (Passo 1 de 2)
        </button>
    
asked by anonymous 23.07.2017 / 03:01

1 answer

0

I used POG (Gambia-oriented Programming)!

ng-required does not accept. Where this if finds nothing, but also does not let pass if it has nothing selected. Neither Alert it gives ... Total POG.

$scope.SelecionaCategoria = function () {



            if (($scope.escolhido.categoria_comida_cod_categoria_com).length === null) {
                slert('É PRECISO UMA CATEGORIA');
            } else {

                $ionicLoading.show();

                var url = "?cod_categoria=" + $scope.escolhido.categoria_comida_cod_categoria_com + "&categoria=" + $scope.escolhido.categoria_comida_nome + ""
                console.log(url);


                var encodedurl = encodeURI(url);
                $ionicLoading.hide();
                window.localStorage.setItem("cod_categoria", $scope.escolhido.categoria_comida_cod_categoria_com);

                $state.go('nhaac.formDelicias');

            }
    
24.07.2017 / 15:20