如何点击一个按钮,制作其他按钮!点击Ionic V1?

时间:2017-04-04 21:04:37

标签: javascript angularjs ionic-framework

<div class="row rowpesquisa">
        <div class="col col-100 colpesquisatop">
        <div class="col col-25">
            <button class="button button-icon buttonsearch" ng-model="butpontoenc" ng-click="butpontoenc.clicked=!butpontoenc.clicked" ng-class="!butpontoenc.clicked?'button-tueddin':'button-tueddin'">
                <img src="img/pesquisar/iconePontoDeEncontro@1x.svg" ng-show="!butpontoenc.clicked">
                <img src="img/pesquisar/iconePontoDeEncontroverde.svg" ng-show="butpontoenc.clicked">
            </button>
        </div>
        <div class="col col-25">
            <button class="button button-icon buttonsearch" ng-model="butpessoas" ng-click="butpessoas.clicked=!butpessoas.clicked" ng-class="!butpessoas.clicked?'button-tueddin':'button-tueddin'">
                <img src="img/pesquisar/iconePessoas@1x.svg" ng-show="!butpessoas.clicked">
                <img src="img/pesquisar/iconePessoasverde.svg" ng-show="butpessoas.clicked">
            </button>
        </div>
        <div class="col col-25">
            <button class="button button-icon buttonsearch" ng-model="butpontotur" ng-click="butpontotur.clicked=!butpontotur.clicked" ng-class="!butpontotur.clicked?'button-tueddin':'button-tueddin'">
                <img src="img/pesquisar/iconePontosTuristicos@1x.svg" ng-show="!butpontotur.clicked">
                <img src="img/pesquisar/iconePontosTuristicosverde.svg" ng-show="butpontotur.clicked">
            </button>
        </div>
        <div class="col col-25">
            <button class="button button-icon buttonsearch" ng-model="butlocais" ng-click="butlocais.clicked=!butlocais.clicked" ng-class="!butlocais.clicked?'button-tueddin':'button-tueddin'">
                <img src="img/pesquisar/iconeLocais@1x.svg" ng-show="!butlocais.clicked">
                <img src="img/pesquisar/iconeLocaisverde.svg" ng-show="butlocais.clicked">
            </button>
        </div>
        </div>
    </div>

所以现在这是我的代码。它是一个搜索页面,可以点击4个按钮,如过滤器。但他们现在的工作方式是让过滤器相互汇总。我需要选择每个过滤器单独显示。为此,当点击任何其他按钮时,我需要单击按钮...我该怎么做?

谢谢

1 个答案:

答案 0 :(得分:0)

你想让它们像单选按钮一样工作吗?

简单的解决方案是在每次点击时将它们设置为false,这样您的第一个看起来就像这样:

ng-click="butpontoenc.clicked = true; butpessoas.clicked = false; butpontotur.clicked = false; butlocais.clicked = false;"

你需要在每个按钮上复制它,或者在控制器上创建一个方法,该方法接收你想要设置的按钮并循环它们并相应地设置每个按钮。