0

如何获得单击时隐藏的开始按钮并显示停止按钮。当我单击停止按钮时,我想看到出现开始按钮。我试过了,但没有。有人有想法吗?

'use strict';
angular.module('djoro.controllers')
.controller('WifiSmartConfigCtrl', function($scope, $window, $ionicPlatform){
  $scope.EventRunning = false;
  $scope.showAlert = function(){
    $ionicPlatform.ready(function(){
      $window.cordova.plugins.Smartconfig.alert('My plugin works !');
    });
  };
  $scope.startSmartconfig = function(){
    var onSuccess = function(success){
      $scope.StartEvent = function (event) {
        event.preventDefault();
        $scope.EventRunning = true;
      };
    };
    var onFail = function(){};
    $ionicPlatform.ready(function(){
      $window.cordova.plugins.Smartconfig.startSmartconfig(onSuccess, onFail, wifiPassword);
    });
  };
  $scope.stopSmartconfig = function(){
    $ionicPlatform.ready(function(){
      var onSuccess = function(){
        $scope.StopEvent = function (event) {
          event.preventDefault();
          $scope.EventRunning = true;
        };
        alert("stopSmartconfig done");
      };
      var onFail = function(){};
      $window.cordova.plugins.Smartconfig.stopSmartconfig(onSuccess, onFail);
    });
  };
)};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>

<div class="startWifi">
                <button ng-hide="EventRunning" class="button button-full button-balanced" ng-click="startSmartconfig($event)">Start</button>
                <button ng-show="EventRunning" class="button button-full button-assertive" ng-click="stopSmartconfig($event)">Stop</button>
</div>

如何获得单击时隐藏的开始按钮并显示停止按钮。当我单击停止按钮时,我想看到出现开始按钮。我试过了,但没有。有人有想法吗?

4

2 回答 2

0
'use strict';

angular.module('djoro.controllers')

 .controller('WifiSmartConfigCtrl', function($scope, $window,    $ionicPlatform){

 $scope.EventRunning = false;

  $scope.showAlert = function(){
 $ionicPlatform.ready(function(){
   $window.cordova.plugins.Smartconfig.alert('My plugin works !');
});
};

$scope.startSmartconfig = function(event){

    var onSuccess = function(success){
        $scope.StartEvent = function (event) {
        event.preventDefault();
        $scope.EventRunning = true;
        };

    };

    var onFail = function(){};

    $ionicPlatform.ready(function(){

    $window.cordova.plugins.Smartconfig.startSmartconfig(onSuccess, onFail, wifiPassword);

    });

 };

 $scope.stopSmartconfig = function(event){
    $ionicPlatform.ready(function(){



      var onSuccess = function(){

        $scope.StopEvent = function (event) {
        event.preventDefault();
        $scope.EventRunning = true;
    };

          alert("stopSmartconfig done");
      };
      var onFail = function(){};

      $window.cordova.plugins.Smartconfig.stopSmartconfig(onSuccess, onFail);
    });



     };

   )};

您的控制器方法您的调用包含一个参数,并且您在方法中没有传递任何参数,请参见上面的代码

于 2015-09-22T12:31:54.553 回答
0

您错误地关闭了代码,我不知道这是否会解决您的问题,但它可能会带来其他问题,因此请替换此:)};});如果您仍然有问题,请检查是否有任何错误。

于 2015-09-22T12:35:07.500 回答