D
D
DimaPolishuk2016-07-24 01:43:20
Angular
DimaPolishuk, 2016-07-24 01:43:20

Directives ng-show, ng-hide, how to use?

There are 2 buttons, when the page is loaded, only one button is visible, how can I make it so that by clicking on the first button, this button disappears and another appears, and vice versa?
Did it like this:

<button class="btn btn-start" ng-click="startOrStop()" ng-bind="buttonText"></button>

var isStart = false;
        var isStop = false;
        $scope.buttonText = "Start";
    
       $scope.startOrStop= function() {
         if (isStart) {
           $scope.start();
           isStart = false;
           isStop = true;
           $scope.buttonText = "Stop";
      } 
      
        if (isStop) {
          $scope.stop();
          isStop = false;
          $scope.buttonText = "Start";
      } else {
          $scope.start();
          isStop = true;
          $scope.buttonText = "Stop";
      }
    };

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nagaev, 2016-07-24
@DimaPolishuk

a=!a

D
Dima, 2017-07-18
@dimakrsna

A good example is here: https://scotch.io/tutorials/how-to-use-ngshow-and-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question