0

ボタン アイコン thext を変更しようとしており、onClick() を無効にしたいと考えています。

残念ながら、最初にクリックするとテキストが変更され、もう一度クリックするとアイコンが変更されますが、無効にはなりません。

スタックでは、変数はクリック イベントの後に正しく設定されます。なぜ機能しないのか、2回クリックすると変わるのか、本当にわかりません。

これが私のhtmlです:

<ion-view title="Who-U">
    <ion-content class="padding">

        <a class="item item-thumbnail-left" href="#">
            <img src="img/cover.png">
            <h2>{{username}}</h2>
            <p>Points: {{points}}</p>
        </a>

        <button ng-click="click()" class="button button-full button-positive" ng-disabled="{{buttonDisable}}">
            <i class='{{buttonType}}'></i>{{text}}
        </button>
    </ion-content>
</ion-view>

それは私のコントローラーです:

angular.module('home', ['services'])

.controller('homeCtrl',
    function ($scope, $location, $state, localStorageService, serverAPI, $ionicPopup) {

       $scope.buttonType = "icon ion-search",
        $scope.buttonDisable = false,
        $scope.text = 'Search',


        $scope.click = function () {
            $scope.buttonDisable = true
            $scope.text = 'Searching'
            $scope.buttonType = "icon ion-loading-a"

        };

    })
4

1 に答える 1

2

「;」を入れるのを忘れています あなたのコードで:p

これを試して :

   $scope.buttonType = "icon ion-search";
    $scope.buttonDisable = false;
    $scope.text = 'Search';


    $scope.click = function () {
        $scope.buttonDisable = true;
        $scope.text = 'Searching';
        $scope.buttonType = "icon ion-loading-a";
}
于 2015-05-04T12:33:00.190 に答える